andre@0: /* This Source Code Form is subject to the terms of the Mozilla Public andre@0: * License, v. 2.0. If a copy of the MPL was not distributed with this andre@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ andre@0: /* andre@0: * pkix_pl_httpdefaultclient.h andre@0: * andre@0: * HTTPDefaultClient Object Type Definition andre@0: * andre@0: */ andre@0: andre@0: #ifndef _PKIX_PL_HTTPDEFAULTCLIENT_H andre@0: #define _PKIX_PL_HTTPDEFAULTCLIENT_H andre@0: andre@0: #include "pkix_pl_common.h" andre@0: andre@0: #ifdef __cplusplus andre@0: extern "C" { andre@0: #endif andre@0: andre@0: #define HTTP_DATA_BUFSIZE 4096 andre@0: #define HTTP_HEADER_BUFSIZE 1024 andre@0: #define HTTP_MIN_AVAILABLE_BUFFER_SIZE 512 andre@0: andre@0: typedef enum { andre@0: HTTP_NOT_CONNECTED, andre@0: HTTP_CONNECT_PENDING, andre@0: HTTP_CONNECTED, andre@0: HTTP_SEND_PENDING, andre@0: HTTP_RECV_HDR, andre@0: HTTP_RECV_HDR_PENDING, andre@0: HTTP_RECV_BODY, andre@0: HTTP_RECV_BODY_PENDING, andre@0: HTTP_COMPLETE, andre@0: HTTP_ERROR andre@0: } HttpConnectStatus; andre@0: andre@0: typedef enum { andre@0: HTTP_POST_METHOD, andre@0: HTTP_GET_METHOD andre@0: } HttpMethod; andre@0: andre@0: struct PKIX_PL_HttpDefaultClientStruct { andre@0: HttpConnectStatus connectStatus; andre@0: PRUint16 portnum; andre@0: PRIntervalTime timeout; andre@0: PKIX_UInt32 bytesToWrite; andre@0: PKIX_UInt32 send_http_data_len; andre@0: PKIX_UInt32 rcv_http_data_len; andre@0: PKIX_UInt32 capacity; andre@0: PKIX_UInt32 filledupBytes; andre@0: PKIX_UInt32 responseCode; andre@0: PKIX_UInt32 maxResponseLen; andre@0: PKIX_UInt32 GETLen; andre@0: PKIX_UInt32 POSTLen; andre@0: PRUint32 *pRcv_http_data_len; andre@0: PRPollDesc pollDesc; andre@0: void *callbackList; /* cast this to (PKIX_PL_Socket_Callback *) */ andre@0: char *GETBuf; andre@0: char *POSTBuf; andre@0: char *rcvBuf; andre@0: char *host; andre@0: char *path; andre@0: char *rcvContentType; andre@0: void *rcvHeaders; andre@0: HttpMethod send_http_method; andre@0: const char *send_http_content_type; andre@0: const char *send_http_data; andre@0: PRUint16 *rcv_http_response_code; andre@0: const char **rcv_http_content_type; andre@0: const char **rcv_http_headers; andre@0: const char **rcv_http_data; andre@0: PKIX_PL_Socket *socket; andre@0: void *plContext; andre@0: }; andre@0: andre@0: /* see source file for function documentation */ andre@0: andre@0: PKIX_Error *pkix_pl_HttpDefaultClient_RegisterSelf(void *plContext); andre@0: andre@0: SECStatus andre@0: pkix_pl_HttpDefaultClient_CreateSessionFcn( andre@0: const char *host, andre@0: PRUint16 portnum, andre@0: SEC_HTTP_SERVER_SESSION *pSession); andre@0: andre@0: SECStatus andre@0: pkix_pl_HttpDefaultClient_KeepAliveSessionFcn( andre@0: SEC_HTTP_SERVER_SESSION session, andre@0: PRPollDesc **pPollDesc); andre@0: andre@0: SECStatus andre@0: pkix_pl_HttpDefaultClient_FreeSessionFcn( andre@0: SEC_HTTP_SERVER_SESSION session); andre@0: andre@0: SECStatus andre@0: pkix_pl_HttpDefaultClient_RequestCreateFcn( andre@0: SEC_HTTP_SERVER_SESSION session, andre@0: const char *http_protocol_variant, /* usually "http" */ andre@0: const char *path_and_query_string, andre@0: const char *http_request_method, andre@0: const PRIntervalTime timeout, andre@0: SEC_HTTP_REQUEST_SESSION *pRequest); andre@0: andre@0: SECStatus andre@0: pkix_pl_HttpDefaultClient_SetPostDataFcn( andre@0: SEC_HTTP_REQUEST_SESSION request, andre@0: const char *http_data, andre@0: const PRUint32 http_data_len, andre@0: const char *http_content_type); andre@0: andre@0: SECStatus andre@0: pkix_pl_HttpDefaultClient_AddHeaderFcn( andre@0: SEC_HTTP_REQUEST_SESSION request, andre@0: const char *http_header_name, andre@0: const char *http_header_value); andre@0: andre@0: SECStatus andre@0: pkix_pl_HttpDefaultClient_TrySendAndReceiveFcn( andre@0: SEC_HTTP_REQUEST_SESSION request, andre@0: PRPollDesc **pPollDesc, andre@0: PRUint16 *http_response_code, andre@0: const char **http_response_content_type, andre@0: const char **http_response_headers, andre@0: const char **http_response_data, andre@0: PRUint32 *http_response_data_len); andre@0: andre@0: SECStatus andre@0: pkix_pl_HttpDefaultClient_CancelFcn( andre@0: SEC_HTTP_REQUEST_SESSION request); andre@0: andre@0: SECStatus andre@0: pkix_pl_HttpDefaultClient_FreeFcn( andre@0: SEC_HTTP_REQUEST_SESSION request); andre@0: andre@0: #ifdef __cplusplus andre@0: } andre@0: #endif andre@0: andre@0: #endif /* _PKIX_PL_HTTPDEFAULTCLIENT_H */