00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _HTTPCLIENT_PROTOCOL_H_
00014 #define _HTTPCLIENT_PROTOCOL_H_
00015
00016 #ifdef __cplusplus
00017 extern "C" {
00018 #endif
00019
00020
00021 #define HTTP_CLIENT_MAX_URL_LENGTH 512 // Maximum length for an HTTP Url parameter
00022
00023
00024 #define HTTP_CLIENT_FLAG_KEEP_ALIVE 0x00000001 // Set the keep alive header
00025 #define HTTP_CLIENT_FLAG_SEND_CHUNKED 0x00000002 // The outgoing should chunked
00026 #define HTTP_CLIENT_FLAG_NO_CACHE 0x00000004 // Set the no cache header
00027 #define HTTP_CLIENT_FLAG_ASYNC 0x00000008 // Currently not implemented
00028
00029
00030 #define HTTP_CLIENT_STATE_PRE_INIT 0x00000000 // Starting stage
00031 #define HTTP_CLIENT_STATE_INIT 0x00000001 // API was initialized (memory was allocated)
00032 #define HTTP_CLIENT_STATE_URL_PARSED 0x00000002 // Url was parsed
00033 #define HTTP_CLIENT_STATE_HOST_CONNECTED 0x00000004 // HEAD verb was sent
00034 #define HTTP_CLIENT_STATE_HEAD_SENT 0x00000008 // Post verb was sent
00035 #define HTTP_CLIENT_STATE_POST_SENT 0x00000010 // HTTP requet was sent
00036 #define HTTP_CLIENT_STATE_REQUEST_SENT 0x00000020 // HTTP request was sent
00037 #define HTTP_CLIENT_STATE_HEADERS_RECIVED 0x00000040 // Headers ware recived from the server
00038 #define HTTP_CLIENT_STATE_HEADERS_PARSED 0x00000080 // HTTP headers ware parsed
00039 #define HTTP_CLIENT_STATE_HEADERS_OK 0x00000100 // Headers status was OK
00040
00041
00042 #define HTTP_CLIENT_SUCCESS 0 // HTTP Success status
00043
00044 #define HTTP_CLIENT_UNKNOWN_ERROR 1 // Unknown error
00045 #define HTTP_CLIENT_ERROR_INVALID_HANDLE 2 // an Invalid handle or possible bad pointer was passed to a function
00046 #define HTTP_CLIENT_ERROR_NO_MEMORY 3 // Buffer too small or a failure while in memory allocation
00047 #define HTTP_CLIENT_ERROR_SOCKET_INVALID 4 // an attempt to use an invalid socket handle was made
00048 #define HTTP_CLIENT_ERROR_SOCKET_CANT_SET 5 // Can't send socket parameters
00049 #define HTTP_CLIENT_ERROR_SOCKET_RESOLVE 6 // Error while resolving host name
00050 #define HTTP_CLIENT_ERROR_SOCKET_CONNECT 7 // Error while connecting to the remote server
00051 #define HTTP_CLIENT_ERROR_SOCKET_TIME_OUT 8 // socket time out error
00052 #define HTTP_CLIENT_ERROR_SOCKET_RECV 9 // Error while receiving data
00053 #define HTTP_CLIENT_ERROR_SOCKET_SEND 10 // Error while sending data
00054 #define HTTP_CLIENT_ERROR_HEADER_RECV 11 // Error while receiving the remote HTTP headers
00055 #define HTTP_CLIENT_ERROR_HEADER_NOT_FOUND 12 // Could not find element within header
00056 #define HTTP_CLIENT_ERROR_HEADER_BIG_CLUE 13 // The headers search clue was too large for the internal API buffer
00057 #define HTTP_CLIENT_ERROR_HEADER_NO_LENGTH 14 // No content length was specified for the outgoing data. the caller should specify chunking mode in the session creation
00058 #define HTTP_CLIENT_ERROR_CHUNK_TOO_BIG 15 // The HTTP chunk token that was received from the server was too big and possibly wrong
00059 #define HTTP_CLIENT_ERROR_AUTH_HOST 16 // Could not authenticate with the remote host
00060 #define HTTP_CLIENT_ERROR_AUTH_PROXY 17 // Could not authenticate with the remote proxy
00061 #define HTTP_CLIENT_ERROR_BAD_VERB 18 // Bad or not supported HTTP verb was passed to a function
00062 #define HTTP_CLIENT_ERROR_LONG_INPUT 19 // a function received a parameter that was too large
00063 #define HTTP_CLIENT_ERROR_BAD_STATE 20 // The session state prevents the current function from proceeding
00064 #define HTTP_CLIENT_ERROR_CHUNK 21 // Could not parse the chunk length while in chunked transfer
00065 #define HTTP_CLIENT_ERROR_BAD_URL 22 // Could not parse curtail elements from the URL (such as the host name, HTTP prefix act')
00066 #define HTTP_CLIENT_ERROR_BAD_HEADER 23 // Could not detect key elements in the received headers
00067 #define HTTP_CLIENT_ERROR_BUFFER_RSIZE 24 // Error while attempting to resize a buffer
00068 #define HTTP_CLIENT_ERROR_BAD_AUTH 25 // Authentication schema is not supported
00069 #define HTTP_CLIENT_ERROR_AUTH_MISMATCH 26 // The selected authentication schema does not match the server response
00070 #define HTTP_CLIENT_ERROR_NO_DIGEST_TOKEN 27 // an element was missing while parsing the digest authentication challenge
00071 #define HTTP_CLIENT_ERROR_NO_DIGEST_ALG 28 // Digest algorithem could be MD5 or MD5-sess other types are not supported
00072 #define HTTP_CLIENT_ERROR_SOCKET_BIND 29 // Binding error
00073 #define HTTP_CLIENT_ERROR_TLS_NEGO 30 // Tls negotiation error
00074 #define HTTP_CLIENT_ERROR_NOT_IMPLEMENTED 64 // Feature is not (yet) implemented
00075 #define HTTP_CLIENT_EOS 1000 // HTTP end of stream message
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 typedef enum _HTTP_AUTH_SCHEMA
00086 {
00087 AuthSchemaNone = 0,
00088 AuthSchemaBasic,
00089 AuthSchemaDigest,
00090 AuthSchemaKerberos,
00091 AuthNotSupported
00092
00093 } HTTP_AUTH_SCHEMA;
00094
00095
00096 typedef enum _HTTP_VERB
00097 {
00098 VerbGet = 0,
00099 VerbHead,
00100 VerbPost,
00101 VerbNotSupported
00102
00103
00104 } HTTP_VERB;
00105
00106
00107 typedef struct _HTTP_CLIENT
00108 {
00109 UINT32 HTTPStatusCode;
00110 UINT32 RequestBodyLengthSent;
00111 UINT32 ResponseBodyLengthReceived;
00112 UINT32 TotalResponseBodyLength;
00113 UINT32 HttpState;
00114 } HTTP_CLIENT;
00115
00116 #ifdef __cplusplus
00117 }
00118 #endif
00119
00120 #endif // _HTTPCLIENT_PROTOCOL_H_