#ifndef __HTTP_DOWNLOAD_FILE_H__ #define __HTTP_DOWNLOAD_FILE_H__
#ifdef HTTPDOWNLOADFILE_EXPORTS #define HTTPDOWNLOADFILE_API __declspec(dllexport) #else #define HTTPDOWNLOADFILE_API /*__declspec(dllimport)*/ #endif
#ifdef __cplusplus extern "C" { #endif
// HTTP Download File Error Codes #define HTTPDF_OK 0x00000000 #define HTTPDF_ERROR_SOCKET 0x00000001 #define HTTPDF_ERROR_URL 0x00000002 #define HTTPDF_ERROR_CONNECT 0x00000003 #define HTTPDF_ERROR_REQUEST 0x00000004 #define HTTPDF_ERROR_FILE_IO 0x00000005 #define HTTPDF_ERROR_TIMEOUT 0x00000006 #define HTTPDF_ERROR_HTTP 0x00000007 #define HTTPDF_ERROR_BUFFER_SIZE 0x00000008 #define HTTPDF_ERROR_USER_CANCELED 0x00000009 #define HTTPDF_ERROR_INVALID_PARAMETER 0x0000000A
// HTTP Download File Flags #define HTTPDF_FLAG_HTTP_ERROR_PAGE 0x00000001 #define HTTPDF_FLAG_CALLBACK 0x00000002 #define HTTPDF_FLAG_GET_FILE_SIZE_ONLY 0x00000004 #define HTTPDF_FLAG_DELETE_INVALID_FILE 0x00000008 #define HTTPDF_FLAG_RESUME_POSITION 0x00000010 #define HTTPDF_FLAG_END_POSITION 0x00000020 #define HTTPDF_FLAG_TIMEOUT 0x00000040
// HTTP Download File Status Codes #define HTTPDF_STATUS_CONNECTING 0x00000001 #define HTTPDF_STATUS_DOWNLOADING 0x00000002
// HTTP Response Status Codes (from wininet.h) #define HTTP_STATUS_CONTINUE 100 // OK to continue with request #define HTTP_STATUS_SWITCH_PROTOCOLS 101 // server has switched protocols in upgrade header
#define HTTP_STATUS_OK 200 // request completed #define HTTP_STATUS_CREATED 201 // object created, reason = new URI #define HTTP_STATUS_ACCEPTED 202 // async completion (TBS) #define HTTP_STATUS_PARTIAL 203 // partial completion #define HTTP_STATUS_NO_CONTENT 204 // no info to return #define HTTP_STATUS_RESET_CONTENT 205 // request completed, but clear form #define HTTP_STATUS_PARTIAL_CONTENT 206 // partial GET furfilled
#define HTTP_STATUS_AMBIGUOUS 300 // server couldn't decide what to return #define HTTP_STATUS_MOVED 301 // object permanently moved #define HTTP_STATUS_REDIRECT 302 // object temporarily moved #define HTTP_STATUS_REDIRECT_METHOD 303 // redirection w/ new access method #define HTTP_STATUS_NOT_MODIFIED 304 // if-modified-since was not modified #define HTTP_STATUS_USE_PROXY 305 // redirection to proxy, location header specifies proxy to use #define HTTP_STATUS_REDIRECT_KEEP_VERB 307 // HTTP/1.1: keep same verb
#define HTTP_STATUS_BAD_REQUEST 400 // invalid syntax #define HTTP_STATUS_DENIED 401 // access denied #define HTTP_STATUS_PAYMENT_REQ 402 // payment required #define HTTP_STATUS_FORBIDDEN 403 // request forbidden #define HTTP_STATUS_NOT_FOUND 404 // object not found #define HTTP_STATUS_BAD_METHOD 405 // method is not allowed #define HTTP_STATUS_NONE_ACCEPTABLE 406 // no response acceptable to client found #define HTTP_STATUS_PROXY_AUTH_REQ 407 // proxy authentication required #define HTTP_STATUS_REQUEST_TIMEOUT 408 // server timed out waiting for request #define HTTP_STATUS_CONFLICT 409 // user should resubmit with more info #define HTTP_STATUS_GONE 410 // the resource is no longer available #define HTTP_STATUS_LENGTH_REQUIRED 411 // the server refused to accept request w/o a length #define HTTP_STATUS_PRECOND_FAILED 412 // precondition given in request failed #define HTTP_STATUS_REQUEST_TOO_LARGE 413 // request entity was too large #define HTTP_STATUS_URI_TOO_LONG 414 // request URI too long #define HTTP_STATUS_UNSUPPORTED_MEDIA 415 // unsupported media type #define HTTP_STATUS_RETRY_WITH 449 // retry after doing the appropriate action.
#define HTTP_STATUS_SERVER_ERROR 500 // internal server error #define HTTP_STATUS_NOT_SUPPORTED 501 // required not supported #define HTTP_STATUS_BAD_GATEWAY 502 // error response received from gateway #define HTTP_STATUS_SERVICE_UNAVAIL 503 // temporarily overloaded #define HTTP_STATUS_GATEWAY_TIMEOUT 504 // timed out waiting for gateway #define HTTP_STATUS_VERSION_NOT_SUP 505 // HTTP version not supported
typedef struct tagDOWNLOADFILEPROGRESS { DWORD dwStatus; DWORD dwHTTPStatusCode; LPCTSTR lpszHostName; LPCTSTR lpszFileRealURL; WORD nPort; LPCTSTR lpszFileName; DWORD dwFileSize; DWORD dwBytesWritten; DWORD dwContentLength; DWORD dwResumePos; DWORD dwTimeElapsed; LPVOID lpParameter;
} DOWNLOADFILEPROGRESS, *LPDOWNLOADFILEPROGRESS;
typedef BOOL (CALLBACK* LPFNHTTPDOWNLOADFILE)(LPDOWNLOADFILEPROGRESS lpProgress);
typedef struct tagHTTPDOWNLOADFILEINFO { DWORD cbSize; DWORD dwFlags; LPCTSTR lpszFileURL; LPTSTR lpszFileSavePath; DWORD dwPathLen; LPCTSTR lpszFileErrorPage; DWORD dwResumePos; DWORD dwEndPos; DWORD dwTimeOut; DWORD dwHTTPStatusCode; DWORD dwFileSize; DWORD dwBytesWritten; DWORD dwError; LPVOID lpParameter; LPVOID lpReserved; LPFNHTTPDOWNLOADFILE pfnCallback; } HTTPDOWNLOADFILEINFO, *LPHTTPDOWNLOADFILEINFO;
HTTPDOWNLOADFILE_API BOOL HTTPDownloadFile(LPHTTPDOWNLOADFILEINFO lpDownloadFileInfo);
#ifdef __cplusplus } #endif
#endif /* __HTTP_DOWNLOAD_FILE_H__ */ |