00001
00006 #ifndef __HTTPAPI__
00007 #define __HTTPAPI__
00008
00009
00010 #ifndef __AFXISAPI_H_ // these symbols may come from WININET.H
00012 #define HTTP_STATUS_CONTINUE 100
00014 #define HTTP_STATUS_SWITCH_PROTOCOLS 101
00016 #define HTTP_STATUS_OK 200
00018 #define HTTP_STATUS_CREATED 201
00020 #define HTTP_STATUS_ACCEPTED 202
00022 #define HTTP_STATUS_PARTIAL 203
00024 #define HTTP_STATUS_NO_CONTENT 204
00026 #define HTTP_STATUS_RESET_CONTENT 205
00028 #define HTTP_STATUS_PARTIAL_CONTENT 206
00030 #define HTTP_STATUS_AMBIGUOUS 300
00032 #define HTTP_STATUS_MOVED 301
00034 #define HTTP_STATUS_REDIRECT 302
00036 #define HTTP_STATUS_REDIRECT_METHOD 303
00038 #define HTTP_STATUS_NOT_MODIFIED 304
00040 #define HTTP_STATUS_USE_PROXY 305
00042 #define HTTP_STATUS_REDIRECT_KEEP_VERB 307
00044 #define HTTP_STATUS_BAD_REQUEST 400
00046 #define HTTP_STATUS_DENIED 401
00048 #define HTTP_STATUS_PAYMENT_REQ 402
00050 #define HTTP_STATUS_FORBIDDEN 403
00052 #define HTTP_STATUS_NOT_FOUND 404
00054 #define HTTP_STATUS_BAD_METHOD 405
00056 #define HTTP_STATUS_NONE_ACCEPTABLE 406
00058 #define HTTP_STATUS_PROXY_AUTH_REQ 407
00060 #define HTTP_STATUS_REQUEST_TIMEOUT 408
00062 #define HTTP_STATUS_CONFLICT 409
00064 #define HTTP_STATUS_GONE 410
00066 #define HTTP_STATUS_LENGTH_REQUIRED 411
00068 #define HTTP_STATUS_PRECOND_FAILED 412
00070 #define HTTP_STATUS_REQUEST_TOO_LARGE 413
00072 #define HTTP_STATUS_URI_TOO_LONG 414
00074 #define HTTP_STATUS_UNSUPPORTED_MEDIA 415
00076 #define HTTP_STATUS_SERVER_ERROR 500
00078 #define HTTP_STATUS_NOT_SUPPORTED 501
00080 #define HTTP_STATUS_BAD_GATEWAY 502
00082 #define HTTP_STATUS_SERVICE_UNAVAIL 503
00084 #define HTTP_STATUS_GATEWAY_TIMEOUT 504
00086 #define HTTP_STATUS_VERSION_NOT_SUP 505
00087 #define HTTP_STATUS_FIRST HTTP_STATUS_CONTINUE
00088 #define HTTP_STATUS_LAST HTTP_STATUS_VERSION_NOT_SUP
00089 #endif
00090
00091
00092
00093
00097 typedef struct _data {
00098 char *Header;
00100 unsigned int HeaderSize;
00102 char *Data;
00104 unsigned int DataSize;
00106 } HTTP_DATA, *PHTTP_DATA;
00107
00108
00112 typedef struct _request {
00113 char hostname[256];
00115 int ip;
00117 int port;
00119 int NeedSSL;
00121 char url[512];
00123 PHTTP_DATA request;
00125 PHTTP_DATA response;
00127 char *server;
00129 unsigned int status;
00131 unsigned int challenge;
00133 } REQUEST, *PREQUEST;
00134
00139 typedef void* HTTPHANDLE;
00140
00141
00142
00143 #define NO_AUTH 0
00144 #define BASIC_AUTH 1
00145 #define DIGEST_AUTH 2
00146 #define NTLM_AUTH 4
00147 #define NEGOTIATE_AUTH 8
00148 #define UNKNOWN_AUTH 16
00149
00150 #define MAX_POST_LENGHT 4096
00151 #define MAX_DOWNLOAD_SIZE MAX_POST_LENGHT*20
00152
00153
00154 #define OPT_HTTP_PROXY_HOST 0x00
00155 #define OPT_HTTP_PROXY_PORT 0x01
00156 #define OPT_HTTP_PROXY_USER 0x02
00157 #define OPT_HTTP_PROXY_PASS 0x04
00158
00159 #define OPT_HTTP_HEADER 0x08
00160 #define OPT_HTTP_COOKIE 0x10
00161 #define OPT_HTTP_USERAGENT 0x20
00162 #define OPT_HTTP_PROTOCOL 0x40
00163 #define OPT_HTTP_MAXSPEED_DOWNLOAD 0x80
00164
00165
00166
00167
00168
00169
00170
00171
00172 #define HTTP_REQUEST_CURRENT 1
00173 #define HTTP_REQUEST_ALL 0
00174
00175
00176
00177 int InitHTTPApi( void );
00178 void CloseHTTPApi( void) ;
00179 int SetHTTPAPIConfig( int opt, char *parameter );
00180 char *GetHTTPAPIConfig( int opt );
00181
00182
00183 HTTPHANDLE InitHTTPConnectionHandle( char *hostname,int port, int ssl );
00184 int SetHTTPConfig( HTTPHANDLE HTTPHandle, int opt, char *parameter );
00185 char *GetHTTPConfig( HTTPHANDLE HTTPHandle, int opt);
00186 void CloseHTTPConnectionHandle( HTTPHANDLE HTTPHandle);
00187
00188
00189 PREQUEST SendHttpRequest( HTTPHANDLE HTTPHandle, char *Vhost, char *HTTPMethod,char *url,char *Postdata,char *lpUsername,char *lpPassword,int AuthMethod);
00190 PREQUEST SendRawHttpRequest( HTTPHANDLE HTTPHandle,char *headers, char *postdata);
00191 void *FreeRequest( PREQUEST request);
00192 int CancelHttpRequest(HTTPHANDLE HTTPHandle, int what);
00193
00194
00195 char* GetHeaderValue(char *headers,char *value,int n);
00196 char* GetHeaderValueByID(char *headers, unsigned int id);
00197 PHTTP_DATA RemoveHeader(PHTTP_DATA request, char *Header);
00198 PHTTP_DATA AddHeader(PHTTP_DATA request,char *Header);
00199
00200
00201
00202 #endif