/// <summary> /// 获取内容长度 /// </summary> /// <param name="connId"></param> /// <returns></returns> public long GetContentLength(IntPtr connId) { return(HttpSdk.HP_HttpAgent_GetContentLength(pAgent, connId)); }
/// <summary> /// 获取内容类型 /// </summary> /// <param name="connId"></param> /// <returns></returns> public string GetContentType(IntPtr connId) { IntPtr ptr = HttpSdk.HP_HttpServer_GetContentType(pServer, connId); return(Common.PtrToAnsiString(ptr)); }
/// <summary> /// 获取协议升级类型 /// </summary> /// <param name="connId"></param> /// <returns></returns> public HttpUpgradeType GetUpgradeType(IntPtr connId) { return(HttpSdk.HP_HttpServer_GetUpgradeType(pServer, connId)); }
/// <summary> /// 检查是否升级协议 /// </summary> /// <param name="connId"></param> /// <returns></returns> public bool IsUpgrade(IntPtr connId) { return(HttpSdk.HP_HttpServer_IsUpgrade(pServer, connId)); }
/// <summary> /// 获取协议版本 /// </summary> /// <param name="connId"></param> /// <returns></returns> public HttpVersion GetVersion(IntPtr connId) { return((HttpVersion)HttpSdk.HP_HttpServer_GetVersion(pServer, connId)); }
/// <summary> /// 名称:释放连接 /// 描述:把连接放入释放队列,等待某个时间(通过 SetReleaseDelay() 设置)关闭连接 /// </summary> /// <param name="connId">连接 ID</param> /// <returns></returns> public bool Release(IntPtr connId) { return(HttpSdk.HP_HttpServer_Release(pServer, connId)); }
/// <summary> /// 获取某个 URL 域值 /// </summary> /// <param name="connId"></param> /// <param name="enField"></param> /// <returns></returns> public string GetUrlField(IntPtr connId, HttpUrlField enField) { IntPtr ptr = HttpSdk.HP_HttpServer_GetUrlField(pServer, connId, enField); return(Common.PtrToAnsiString(ptr)); }
/// <summary> /// 发送 CONNECT 请求 /// </summary> /// <param name="connId"></param> /// <param name="path"></param> /// <param name="headers"></param> /// <returns></returns> public bool SendConnect(string path, THeader[] headers) { int headersLength = headers == null ? 0 : headers.Length; return(HttpSdk.HP_HttpClient_SendConnect(pClient, path, headers, headersLength)); }
/// <summary> /// 启动 HTTP 通信, 当通信组件设置为非自动启动 HTTP 通信时,需要调用本方法启动 HTTP 通信 /// </summary> /// <param name="connId"></param> /// <returns></returns> public bool StartHttp() { return(HttpSdk.HP_HttpClient_StartHttp(pClient)); }
/// <summary> /// 名称:发送本地文件 /// 描述:向指定连接发送 4096 KB 以下的小文件 /// </summary> /// <param name="connId"></param> /// <param name="fileName"></param> /// <param name="method"></param> /// <param name="path"></param> /// <param name="headers"></param> /// <returns></returns> public bool SendLocalFile(string fileName, HttpMethod method, string path, THeader[] headers) { int headersLength = headers == null ? 0 : headers.Length; return(HttpSdk.HP_HttpClient_SendLocalFile(pClient, fileName, method.ToString(), path, headers, headersLength)); }
/// <summary> /// 发送 WSMessage 请求 /// </summary> /// <param name="dwConnID"></param> /// <param name="bFinal"></param> /// <param name="iReserved"></param> /// <param name="iOperationCode"></param> /// <param name="lpszMask"></param> /// <param name="Data"></param> /// <param name="ullBodyLen"></param> /// <returns></returns> public bool SendWSMessage(bool bFinal, byte iReserved, byte iOperationCode, byte[] lpszMask, byte[] pData, ulong ullBodyLen) { return(HttpSdk.HP_HttpClient_SendWSMessage(pClient, bFinal, iReserved, iOperationCode, lpszMask, pData, pData.Length, ullBodyLen)); }
/**************************************************************************/ /***************************** Agent 操作方法 ******************************/ /// <summary> /// 发送请求 /// </summary> /// <param name="connId"></param> /// <param name="method">请求方法</param> /// <param name="path">请求路径</param> /// <param name="headers">请求头</param> /// <param name="body">请求体</param> /// <returns></returns> public bool SendRequest(HttpMethod method, string path, THeader[] headers, byte[] body, int bodyLength) { int headersLength = headers == null ? 0 : headers.Length; return(HttpSdk.HP_HttpClient_SendRequest(pClient, method.ToString(), path, headers, headersLength, body, bodyLength)); }
public bool SendWSMessage(IntPtr connId, byte[] data) { int bodyLen = data == null ? 0 : data.Length; return(HttpSdk.HP_HttpServer_SendWSMessage(pServer, connId, true, WSReserved.Off, WSOpcode.Text, null, data, bodyLen, 0)); }
/// <summary> /// 获取协议升级类型 /// </summary> /// <param name="connId"></param> /// <returns></returns> public HttpUpgradeType GetUpgradeType(IntPtr connId) { return(HttpSdk.HP_HttpAgent_GetUpgradeType(pAgent, connId)); }
/**************************************************************************/ /***************************** Server 操作方法 *****************************/ /// <summary> /// 名称:回复请求 /// 描述:向客户端回复 HTTP 请求 /// </summary> /// <param name="connId">连接 ID</param> /// <param name="httpStatusCode">HTTP 状态码</param> /// <param name="desc">HTTP 状态描述</param> /// <param name="headers">回复请求头</param> /// <param name="body">回复请求体</param> /// <returns></returns> public bool SendResponse(IntPtr connId, HttpStatusCode httpStatusCode, string desc, THeader[] headers, byte[] body, int bodyLength) { int headersLength = headers == null ? 0 : headers.Length; return(HttpSdk.HP_HttpServer_SendResponse(pServer, connId, (ushort)httpStatusCode, desc, headers, headersLength, body, bodyLength)); }
/// <summary> /// 获取 HTTP 状态码 /// </summary> /// <param name="connId"></param> /// <returns></returns> public HttpStatusCode GetStatusCode(IntPtr connId) { // 有没有可能获取到未定义的状态码??? return((HttpStatusCode)HttpSdk.HP_HttpClient_GetStatusCode(pClient)); }
/// <summary> /// 名称:发送本地文件 /// 描述:向指定连接发送 4096 KB 以下的小文件 /// </summary> /// <param name="connId"></param> /// <param name="fileName"></param> /// <param name="httpStatusCode"></param> /// <param name="desc"></param> /// <param name="headers"></param> /// <returns></returns> public bool SendLocalFile(IntPtr connId, string fileName, HttpStatusCode httpStatusCode, string desc, THeader[] headers) { int headersLength = headers == null ? 0 : headers.Length; return(HttpSdk.HP_HttpServer_SendLocalFile(pServer, connId, fileName, (ushort)httpStatusCode, desc, headers, headersLength)); }
/// <summary> /// 检查是否升级协议 /// </summary> /// <param name="connId"></param> /// <returns></returns> public bool IsUpgrade(IntPtr connId) { return(HttpSdk.HP_HttpClient_IsUpgrade(pClient)); }
/// <summary> /// 获取请求行 URL 域掩码(URL 域参考:HttpUrlField) /// </summary> /// <param name="connId"></param> /// <returns></returns> public HttpUrlField GetUrlFieldSet(IntPtr connId) { return((HttpUrlField)HttpSdk.HP_HttpServer_GetUrlFieldSet(pServer, connId)); }
/// <summary> /// 检查是否有 Keep-Alive 标识 /// </summary> /// <param name="connId"></param> /// <returns></returns> public bool IsKeepAlive(IntPtr connId) { return(HttpSdk.HP_HttpClient_IsKeepAlive(pClient)); }
/// <summary> /// 获取请求方法 /// </summary> /// <param name="connId"></param> /// <returns></returns> public string GetMethod(IntPtr connId) { IntPtr ptr = HttpSdk.HP_HttpServer_GetMethod(pServer, connId); return(Common.PtrToAnsiString(ptr)); }
/// <summary> /// 获取协议版本 /// </summary> /// <param name="connId"></param> /// <returns></returns> public HttpVersion GetVersion(IntPtr connId) { return((HttpVersion)HttpSdk.HP_HttpClient_GetVersion(pClient)); }
/// <summary> /// 检查是否有 Keep-Alive 标识 /// </summary> /// <param name="connId"></param> /// <returns></returns> public bool IsKeepAlive(IntPtr connId) { return(HttpSdk.HP_HttpServer_IsKeepAlive(pServer, connId)); }
/// <summary> /// 获取内容长度 /// </summary> /// <param name="connId"></param> /// <returns></returns> public long GetContentLength(IntPtr connId) { return(HttpSdk.HP_HttpClient_GetContentLength(pClient)); }
/// <summary> /// 获取内容长度 /// </summary> /// <param name="connId"></param> /// <returns></returns> public long GetContentLength(IntPtr connId) { return(HttpSdk.HP_HttpServer_GetContentLength(pServer, connId)); }
/// <summary> /// 获取内容类型 /// </summary> /// <returns></returns> public string GetContentEncoding(IntPtr connId) { IntPtr ptr = HttpSdk.HP_HttpClient_GetContentEncoding(pClient); return(Common.PtrToAnsiString(ptr)); }
/// <summary> /// 获取传输编码 /// </summary> /// <returns></returns> public string GetTransferEncoding(IntPtr connId) { IntPtr ptr = HttpSdk.HP_HttpServer_GetTransferEncoding(pServer, connId); return(Common.PtrToAnsiString(ptr)); }
/// <summary> /// 获取协议升级类型 /// </summary> /// <param name="connId"></param> /// <returns></returns> public HttpUpgradeType GetUpgradeType(IntPtr connId) { return(HttpSdk.HP_HttpClient_GetUpgradeType(pClient)); }
public bool SendMessage(IntPtr connId, WSMessageState state, IntPtr pData, int length) { return(HttpSdk.HP_HttpServer_SendWSMessage(pServer, connId, state.Final, state.Reserved, state.OperationCode, state.Mask, pData, length, 0)); }
/// <summary> /// 获取协议版本 /// </summary> /// <param name="connId"></param> /// <returns></returns> public HttpVersion GetVersion(IntPtr connId) { return((HttpVersion)HttpSdk.HP_HttpAgent_GetVersion(pAgent, connId)); }