View Issue Details

IDProjectCategoryView StatusLast Update
0030650FPCPackagespublic2019-09-29 18:29
ReporterMichal GawryckiAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
PlatformwinOSOS Version
Product Version3.1.1Product Build 
Target Version3.2.0Fixed in Version3.1.1 
Summary0030650: No header file for WinHTTP
DescriptionFPC does not have a header file for WinHTTP.
I found one on github:
https://github.com/yryz/winhttp/blob/master/WinHttp_h.pas

Attached refactored fiile for FPC.
TagsNo tags attached.
Fixed in Revision36677
FPCOldBugId
FPCTarget
Attached Files
  • winhttp.pas (44,059 bytes)
    unit winhttp;
    
    interface
    
    uses
      Windows;
    
    {*
     * Set up Structure Packing to be 4 bytes for all winhttp structures
     *}
     {$ifdef win64}
       {$packrecords 8}
     {$else}
       {$packrecords 4}
     {$endif}
    
    const
      Winhttpdll = 'Winhttp.dll';
    
    //
    // types
    //
    type
      HINTERNET = Pointer;
      PHINTERNET = ^HINTERNET;
      LPHINTERNET = PHINTERNET;
    
      INTERNET_PORT = WORD;
      PINTERNET_PORT = ^INTERNET_PORT;
      LPINTERNET_PORT = PINTERNET_PORT;
    
    //
    // manifests
    //
    const
    
      INTERNET_DEFAULT_PORT         = 0;           // use the protocol-specific default
      INTERNET_DEFAULT_HTTP_PORT    = 80;          //    "     "  HTTP   "
      INTERNET_DEFAULT_HTTPS_PORT   = 443;         //    "     "  HTTPS  "
    
    // flags for WinHttpOpen():
      WINHTTP_FLAG_ASYNC            = $10000000;   // this session is asynchronous (where supported)
    
    // flags for WinHttpOpenRequest():
      WINHTTP_FLAG_SECURE               = $00800000;  // use SSL if applicable (HTTPS)
      WINHTTP_FLAG_ESCAPE_PERCENT       = $00000004;  // if escaping enabled, escape percent as well
      WINHTTP_FLAG_NULL_CODEPAGE        = $00000008;  // assume all symbols are ASCII, use fast convertion
      WINHTTP_FLAG_BYPASS_PROXY_CACHE   = $00000100;  // add "pragma: no-cache" request header
      WINHTTP_FLAG_REFRESH              = WINHTTP_FLAG_BYPASS_PROXY_CACHE;
      WINHTTP_FLAG_ESCAPE_DISABLE       = $00000040;  // disable escaping
      WINHTTP_FLAG_ESCAPE_DISABLE_QUERY = $00000080;  // if escaping enabled escape path part, but do not escape query
    
    
      SECURITY_FLAG_IGNORE_UNKNOWN_CA        = $00000100;
      SECURITY_FLAG_IGNORE_CERT_DATE_INVALID = $00002000; // expired X509 Cert.
      SECURITY_FLAG_IGNORE_CERT_CN_INVALID   = $00001000; // bad common name in X509 Cert.
      SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE  = $00000200;
    
    
    //
    // WINHTTP_ASYNC_RESULT - this structure is returned to the application via
    // the callback with WINHTTP_CALLBACK_STATUS_REQUEST_COMPLETE. It is not sufficient to
    // just return the result of the async operation. If the API failed then the
    // app cannot call GetLastError() because the thread context will be incorrect.
    // Both the value returned by the async API and any resultant error code are
    // made available. The app need not check dwError if dwResult indicates that
    // the API succeeded (in this case dwError will be ERROR_SUCCESS)
    //
    
    type
      PWinHttpAsyncResult = ^TWinHttpAsyncResult;
      WINHTTP_ASYNC_RESULT = record
        dwResult: DWORD_PTR;  // indicates which async API has encountered an error
        dwError: DWORD;       // the error code if the API failed
      end;
      TWinHttpAsyncResult = WINHTTP_ASYNC_RESULT;
    
    //
    // HTTP_VERSION_INFO - query or set global HTTP version (1.0 or 1.1)
    //
    
      PHttpVersionInfo = ^THttpVersionInfo;
      HTTP_VERSION_INFO = record
        dwMajorVersion: DWORD;
        dwMinorVersion: DWORD;
      end;
      THttpVersionInfo = HTTP_VERSION_INFO;
    
    //
    // INTERNET_SCHEME - URL scheme type
    //
    
      INTERNET_SCHEME = Integer;
      TInternetScheme = INTERNET_SCHEME;
      PInternetScheme = ^TInternetScheme;
    
    const
      INTERNET_SCHEME_HTTP      = (1);
      INTERNET_SCHEME_HTTPS     = (2);
    
    
    //
    // URL_COMPONENTS - the constituent parts of an URL. Used in WinHttpCrackUrl()
    // and WinHttpCreateUrl()
    //
    // For WinHttpCrackUrl(), if a pointer field and its corresponding length field
    // are both 0 then that component is not returned. If the pointer field is NULL
    // but the length field is not zero, then both the pointer and length fields are
    // returned if both pointer and corresponding length fields are non-zero then
    // the pointer field points to a buffer where the component is copied. The
    // component may be un-escaped, depending on dwFlags
    //
    // For WinHttpCreateUrl(), the pointer fields should be NULL if the component
    // is not required. If the corresponding length field is zero then the pointer
    // field is the address of a zero-terminated string. If the length field is not
    // zero then it is the string length of the corresponding pointer field
    //
    
    //#pragma warning( disable : 4121 )   // disable alignment warning
    
    type
      PURLComponents = ^TURLComponents;
      URL_COMPONENTS = record
        dwStructSize: DWORD;       // size of this structure. Used in version check
        lpszScheme: LPWSTR;        // pointer to scheme name
        dwSchemeLength: DWORD;     // length of scheme name
        nScheme: TInternetScheme;  // enumerated scheme type (if known)
        lpszHostName: LPWSTR;      // pointer to host name
        dwHostNameLength: DWORD;   // length of host name
        nPort: INTERNET_PORT;      // converted port number
        lpszUserName: LPWSTR;      // pointer to user name
        dwUserNameLength: DWORD;   // length of user name
        lpszPassword: LPWSTR;      // pointer to password
        dwPasswordLength: DWORD;   // length of password
        lpszUrlPath: LPWSTR;       // pointer to URL-path
        dwUrlPathLength: DWORD;    // length of URL-path
        lpszExtraInfo: LPWSTR;     // pointer to extra information (e.g. ?foo or #foo)
        dwExtraInfoLength: DWORD;  // length of extra information
      end;
      TURLComponents = URL_COMPONENTS;
    
      TURLComponentsW = TURLComponents;
      PURLComponentsW = PURLComponents;
    
    //#pragma warning( default : 4121 )   // restore alignment warning
    
    //
    // WINHTTP_PROXY_INFO - structure supplied with WINHTTP_OPTION_PROXY to get/
    // set proxy information on a WinHttpOpen() handle
    //
    
      PWinHttpProxyInfo = ^TWinHttpProxyInfo;
      WINHTTP_PROXY_INFO = record
        dwAccessType: DWORD;       // see WINHTTP_ACCESS_* types below
        lpszProxy: LPWSTR;         // proxy server list
        lpszProxyBypass: LPWSTR;   // proxy bypass list
      end;
      TWinHttpProxyInfo = WINHTTP_PROXY_INFO;
    
      TWinHttpProxyInfoW = TWinHttpProxyInfo;
      PWinHttpProxyInfoW = PWinHttpProxyInfo;
    
      PWinHttpAutoProxyOptions = ^TWinHttpAutoProxyOptions;
      WINHTTP_AUTOPROXY_OPTIONS = record
        dwFlags: DWORD;
        dwAutoDetectFlags: DWORD;
        lpszAutoConfigUrl: LPCWSTR;
        lpvReserved: Pointer;
        dwReserved: WORD;
        fAutoLogonIfChallenged: BOOL;
      end;
      TWinHttpAutoProxyOptions = WINHTTP_AUTOPROXY_OPTIONS;
    
    const
      WINHTTP_AUTOPROXY_AUTO_DETECT         = $00000001;
      WINHTTP_AUTOPROXY_CONFIG_URL          = $00000002;
      WINHTTP_AUTOPROXY_RUN_INPROCESS       = $00010000;
      WINHTTP_AUTOPROXY_RUN_OUTPROCESS_ONLY = $00020000;
    //
    // Flags for dwAutoDetectFlags
    //
      WINHTTP_AUTO_DETECT_TYPE_DHCP         = $00000001;
      WINHTTP_AUTO_DETECT_TYPE_DNS_A        = $00000002;
    
    
    //
    // WINHTTP_CERTIFICATE_INFO lpBuffer - contains the certificate returned from
    // the server
    //
    type
      WINHTTP_CERTIFICATE_INFO = record
        //
        // ftExpiry - date the certificate expires.
        //
    
        ftExpiry: TFileTime;
    
        //
        // ftStart - date the certificate becomes valid.
        //
    
        ftStart: TFileTime;
    
        //
        // lpszSubjectInfo - the name of organization, site, and server
        //   the cert. was issued for.
        //
    
        lpszSubjectInfo: LPWSTR;
    
        //
        // lpszIssuerInfo - the name of orgainzation, site, and server
        //   the cert was issues by.
        //
    
        lpszIssuerInfo: LPWSTR;
    
        //
        // lpszProtocolName - the name of the protocol used to provide the secure
        //   connection.
        //
    
        lpszProtocolName: LPWSTR;
    
        //
        // lpszSignatureAlgName - the name of the algorithm used for signing
        //  the certificate.
        //
    
        lpszSignatureAlgName: LPWSTR;
    
        //
        // lpszEncryptionAlgName - the name of the algorithm used for
        //  doing encryption over the secure channel (SSL) connection.
        //
    
        lpszEncryptionAlgName: LPWSTR;
    
        //
        // dwKeySize - size of the key.
        //
    
        dwKeySize: DWORD;
    
      end;
      TWinHttpCertificateInfo = WINHTTP_CERTIFICATE_INFO;
    
    {#ifdef _WS2DEF_
    
      WINHTTP_CONNECTION_INFO = record
        cbSize: DWORD;
        LocalAddress: SOCKADDR_STORAGE;  // local ip, local port
        RemoteAddress: SOCKADDR_STORAGE; // remote ip, remote port
      end;
      TWinHttpConnectionInfo = WINHTTP_CONNECTION_INFO;
    
    #endif}
    
    //
    // prototypes
    //
    
    //
    // constants for WinHttpTimeFromSystemTime
    //
    const
      WINHTTP_TIME_FORMAT_BUFSIZE  = 62;
    
    
    function WinHttpTimeFromSystemTime
    (
       pst: PSystemTime; // input GMT time
       pwszTime: LPWSTR  // output string buffer
    ): BOOL; stdcall; external Winhttpdll name 'WinHttpTimeFromSystemTime';
    
    function WinHttpTimeToSystemTime
    (
       pwszTime: LPCWSTR;      // NULL terminated string
       pst: PSystemTime        // output in GMT time
    ): BOOL; stdcall; external Winhttpdll name 'WinHttpTimeToSystemTime';
    
    
    //
    // flags for CrackUrl() and CombineUrl()
    //
    const
      ICU_NO_ENCODE          = $20000000;  // Don't convert unsafe characters to escape sequence
      ICU_DECODE             = $10000000;  // Convert %XX escape sequences to characters
      ICU_NO_META            = $08000000;  // Don't convert .. etc. meta path sequences
      ICU_ENCODE_SPACES_ONLY = $04000000;  // Encode spaces only
      ICU_BROWSER_MODE       = $02000000;  // Special encode/decode rules for browser
      ICU_ENCODE_PERCENT     = $00001000;  // Encode any percent (ASCII25)
    
      // signs encountered, default is to not encode percent.
    
    
    function WinHttpCrackUrl
    (
       pwszUrl: LPCWSTR;
       dwUrlLength: DWORD;
       dwFlags: DWORD;
       lpUrlComponents: PURLComponents
    ): BOOL; stdcall; external Winhttpdll name 'WinHttpCrackUrl';
    
    function WinHttpCreateUrl
    (
       lpUrlComponents: PURLComponents;
       dwFlags: DWORD;
       pwszUrl: LPWSTR;
       lpdwUrlLength: LPDWORD
    ): BOOL; stdcall; external Winhttpdll name 'WinHttpCreateUrl';
    
    //
    // flags for WinHttpCrackUrl() and WinHttpCreateUrl()
    //
    const
      ICU_ESCAPE           = DWORD($80000000); // (un)escape URL characters
      ICU_ESCAPE_AUTHORITY = $00002000;  // causes InternetCreateUrlA to escape chars in authority components (user, pwd, host)
      ICU_REJECT_USERPWD   = $00004000;  // rejects usrls whick have username/pwd sections
    
    function WinHttpCheckPlatform: BOOL; cdecl; external Winhttpdll name 'WinHttpCheckPlatform';
    
    function WinHttpGetDefaultProxyConfiguration(pProxyInfo: PWinHttpProxyInfo): BOOL; stdcall; external Winhttpdll name 'WinHttpGetDefaultProxyConfiguration';
    function WinHttpSetDefaultProxyConfiguration(pProxyInfo: PWinHttpProxyInfo): BOOL; stdcall; external Winhttpdll name 'WinHttpDefaultProxyConfiguration';
    
    
    function WinHttpOpen
    (
       pszAgentW: LPCWSTR;
       dwAccessType: DWORD;
       pszProxyW: LPCWSTR;
       pszProxyBypassW: LPCWSTR;
       dwFlags: DWORD
    ): HINTERNET; stdcall; external Winhttpdll name 'WinHttpOpen';
    
    // WinHttpOpen dwAccessType values (also for WINHTTP_PROXY_INFO::dwAccessType)
    const
      WINHTTP_ACCESS_TYPE_DEFAULT_PROXY             = 0;
      WINHTTP_ACCESS_TYPE_NO_PROXY                  = 1;
      WINHTTP_ACCESS_TYPE_NAMED_PROXY               = 3;
    
    // WinHttpOpen prettifiers for optional parameters
      WINHTTP_NO_PROXY_NAME    = nil;
      WINHTTP_NO_PROXY_BYPASS  = nil;
    
    
    function WinHttpCloseHandle
    (
       hInternet: HINTERNET
    ): BOOL; stdcall; external Winhttpdll name 'WinHttpCloseHandle';
    
    
    function WinHttpConnect
    (
       hSession: HINTERNET;
       pswzServerName: LPCWSTR;
       nServerPort: INTERNET_PORT;
       dwReserved: DWORD
    ): HINTERNET; stdcall; external Winhttpdll name 'WinHttpConnect';
    
    
    function WinHttpReadData
    (
       hRequest: HINTERNET;
       lpBuffer: Pointer;
       dwNumberOfBytesToRead: DWORD;
       lpdwNumberOfBytesRead: LPDWORD
    ): BOOL; stdcall; external Winhttpdll name 'WinHttpReadData';
    
    
    function WinHttpWriteData
    (
       hRequest: HINTERNET;
       lpBuffer: Pointer;
       dwNumberOfBytesToWrite: DWORD;
       lpdwNumberOfBytesWritten: LPDWORD
    ): BOOL; stdcall; external Winhttpdll name 'WinHttpWriteData';
    
    
    function WinHttpQueryDataAvailable
    (
       hRequest: HINTERNET;
       lpdwNumberOfBytesAvailable: LPDWORD
    ): BOOL; stdcall; external Winhttpdll name 'WinHttpQueryDataAvailable';
    
    
    function WinHttpQueryOption
    (
       hInternet: HINTERNET;
       dwOption: DWORD;
       lpBuffer: Pointer;
       lpdwBufferLength: LPDWORD
    ): BOOL; stdcall; external Winhttpdll name 'WinHttpQueryOption';
    
    const
      WINHTTP_NO_CLIENT_CERT_CONTEXT = nil;
    
    function WinHttpSetOption
    (
       hInternet: HINTERNET;
       dwOption: DWORD;
       lpBuffer: Pointer;
       dwBufferLength: DWORD
    ): BOOL; stdcall; external Winhttpdll name 'WinHttpSetOption';
    
    
    function WinHttpSetTimeouts
    (
       hInternet: HINTERNET;           // Session/Request handle.
       nResolveTimeout: Integer;
       nConnectTimeout: Integer;
       nSendTimeout: Integer;
       nReceiveTimeout: Integer
    ): BOOL; stdcall; external Winhttpdll name 'WinHttpSetTimeouts';
    
    //
    // options manifests for WinHttp{Query|Set}Option
    //
    const
      WINHTTP_FIRST_OPTION                         =  1; //WINHTTP_OPTION_CALLBACK;
    
      WINHTTP_OPTION_CALLBACK                      =  1;
      WINHTTP_OPTION_RESOLVE_TIMEOUT               =  2;
      WINHTTP_OPTION_CONNECT_TIMEOUT               =  3;
      WINHTTP_OPTION_CONNECT_RETRIES               =  4;
      WINHTTP_OPTION_SEND_TIMEOUT                  =  5;
      WINHTTP_OPTION_RECEIVE_TIMEOUT               =  6;
      WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT      =  7;
      WINHTTP_OPTION_HANDLE_TYPE                   =  9;
      WINHTTP_OPTION_READ_BUFFER_SIZE              = 12;
      WINHTTP_OPTION_WRITE_BUFFER_SIZE             = 13;
      WINHTTP_OPTION_PARENT_HANDLE                 = 21;
      WINHTTP_OPTION_EXTENDED_ERROR                = 24;
      WINHTTP_OPTION_SECURITY_FLAGS                = 31;
      WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT   = 32;
      WINHTTP_OPTION_URL                           = 34;
      WINHTTP_OPTION_SECURITY_KEY_BITNESS          = 36;
      WINHTTP_OPTION_PROXY                         = 38;
    
    
      WINHTTP_OPTION_USER_AGENT                    = 41;
      WINHTTP_OPTION_CONTEXT_VALUE                 = 45;
      WINHTTP_OPTION_CLIENT_CERT_CONTEXT           = 47;
      WINHTTP_OPTION_REQUEST_PRIORITY              = 58;
      WINHTTP_OPTION_HTTP_VERSION                  = 59;
      WINHTTP_OPTION_DISABLE_FEATURE               = 63;
    
      WINHTTP_OPTION_CODEPAGE                      = 68;
      WINHTTP_OPTION_MAX_CONNS_PER_SERVER          = 73;
      WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER      = 74;
      WINHTTP_OPTION_AUTOLOGON_POLICY              = 77;
      WINHTTP_OPTION_SERVER_CERT_CONTEXT           = 78;
      WINHTTP_OPTION_ENABLE_FEATURE                = 79;
      WINHTTP_OPTION_WORKER_THREAD_COUNT           = 80;
      WINHTTP_OPTION_PASSPORT_COBRANDING_TEXT      = 81;
      WINHTTP_OPTION_PASSPORT_COBRANDING_URL       = 82;
      WINHTTP_OPTION_CONFIGURE_PASSPORT_AUTH       = 83;
      WINHTTP_OPTION_SECURE_PROTOCOLS              = 84;
      WINHTTP_OPTION_ENABLETRACING                 = 85;
      WINHTTP_OPTION_PASSPORT_SIGN_OUT             = 86;
      WINHTTP_OPTION_PASSPORT_RETURN_URL           = 87;
      WINHTTP_OPTION_REDIRECT_POLICY               = 88;
      WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS  = 89;
      WINHTTP_OPTION_MAX_HTTP_STATUS_CONTINUE      = 90;
      WINHTTP_OPTION_MAX_RESPONSE_HEADER_SIZE      = 91;
      WINHTTP_OPTION_MAX_RESPONSE_DRAIN_SIZE       = 92;
      WINHTTP_OPTION_CONNECTION_INFO               = 93;
      WINHTTP_OPTION_CLIENT_CERT_ISSUER_LIST       = 94;
      WINHTTP_OPTION_SPN                           = 96;
    
      WINHTTP_OPTION_GLOBAL_PROXY_CREDS            = 97;
      WINHTTP_OPTION_GLOBAL_SERVER_CREDS           = 98;
    
      WINHTTP_OPTION_UNLOAD_NOTIFY_EVENT           = 99;
      WINHTTP_OPTION_REJECT_USERPWD_IN_URL         = 100;
      WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS = 101;
    
    
      WINHTTP_LAST_OPTION                          = WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS;
    
      WINHTTP_OPTION_USERNAME                      = $1000;
      WINHTTP_OPTION_PASSWORD                      = $1001;
      WINHTTP_OPTION_PROXY_USERNAME                = $1002;
      WINHTTP_OPTION_PROXY_PASSWORD                = $1003;
    
    
    // manifest value for WINHTTP_OPTION_MAX_CONNS_PER_SERVER and WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER
      WINHTTP_CONNS_PER_SERVER_UNLIMITED   = DWORD($FFFFFFFF);
    
    
    // values for WINHTTP_OPTION_AUTOLOGON_POLICY
      WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM  = 0;
      WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW     = 1;
      WINHTTP_AUTOLOGON_SECURITY_LEVEL_HIGH    = 2;
    
      WINHTTP_AUTOLOGON_SECURITY_LEVEL_DEFAULT      = WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM;
    
    // values for WINHTTP_OPTION_REDIRECT_POLICY
      WINHTTP_OPTION_REDIRECT_POLICY_NEVER                      = 0;
      WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP     = 1;
      WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS                     = 2;
    
      WINHTTP_OPTION_REDIRECT_POLICY_LAST          = WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS;
      WINHTTP_OPTION_REDIRECT_POLICY_DEFAULT       = WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP;
    
      WINHTTP_DISABLE_PASSPORT_AUTH    = $00000000;
      WINHTTP_ENABLE_PASSPORT_AUTH     = $10000000;
      WINHTTP_DISABLE_PASSPORT_KEYRING = $20000000;
      WINHTTP_ENABLE_PASSPORT_KEYRING  = $40000000;
    
    
    // values for WINHTTP_OPTION_DISABLE_FEATURE
      WINHTTP_DISABLE_COOKIES                 = $00000001;
      WINHTTP_DISABLE_REDIRECTS               = $00000002;
      WINHTTP_DISABLE_AUTHENTICATION          = $00000004;
      WINHTTP_DISABLE_KEEP_ALIVE              = $00000008;
    
    // values for WINHTTP_OPTION_ENABLE_FEATURE
      WINHTTP_ENABLE_SSL_REVOCATION           = $00000001;
      WINHTTP_ENABLE_SSL_REVERT_IMPERSONATION = $00000002;
    
    // values for WINHTTP_OPTION_SPN
      WINHTTP_DISABLE_SPN_SERVER_PORT         = $00000000;
      WINHTTP_ENABLE_SPN_SERVER_PORT          = $00000001;
      WINHTTP_OPTION_SPN_MASK                 = WINHTTP_ENABLE_SPN_SERVER_PORT;
    type
      PWinHttpCreds = ^TWinHttpCreds;
      tagWINHTTP_CREDS = record
        lpszUserName: LPSTR;
        lpszPassword: LPSTR;
        lpszRealm: LPSTR;
        dwAuthScheme: DWORD;
        lpszHostName: LPSTR;
        dwPort: DWORD;
      end;
      TWinHttpCreds = tagWINHTTP_CREDS;
    
      WINHTTP_CREDS = tagWINHTTP_CREDS;
      PWINHTTP_CREDS = ^tagWINHTTP_CREDS;
    
    // structure for WINHTTP_OPTION_GLOBAL_SERVER_CREDS and
    // WINHTTP_OPTION_GLOBAL_PROXY_CREDS
      PWinHttpCredsEx = ^TWinHttpCredsEx;
      tagWINHTTP_CREDS_EX = record
        lpszUserName: LPSTR;
        lpszPassword: LPSTR;
        lpszRealm: LPSTR;
        dwAuthScheme: DWORD;
        lpszHostName: DWORD;
        dwPort: DWORD;
        lpszUrl: LPSTR;
      end;
      TWinHttpCredsEx = tagWINHTTP_CREDS_EX;
    
      WINHTTP_CREDS_EX = tagWINHTTP_CREDS_EX;
      PWINHTTP_CREDS_EX = ^tagWINHTTP_CREDS_EX;
    
    //
    // winhttp handle types
    //
    const
      WINHTTP_HANDLE_TYPE_SESSION                = 1;
      WINHTTP_HANDLE_TYPE_CONNECT                = 2;
      WINHTTP_HANDLE_TYPE_REQUEST                = 3;
    
    //
    // values for auth schemes
    //
      WINHTTP_AUTH_SCHEME_BASIC     = $00000001;
      WINHTTP_AUTH_SCHEME_NTLM      = $00000002;
      WINHTTP_AUTH_SCHEME_PASSPORT  = $00000004;
      WINHTTP_AUTH_SCHEME_DIGEST    = $00000008;
      WINHTTP_AUTH_SCHEME_NEGOTIATE = $00000010;
    
    // WinHttp supported Authentication Targets
    
      WINHTTP_AUTH_TARGET_SERVER = $00000000;
      WINHTTP_AUTH_TARGET_PROXY  = $00000001;
    
    //
    // values for WINHTTP_OPTION_SECURITY_FLAGS
    //
    
    // query only
      SECURITY_FLAG_SECURE                  = $00000001; // can query only
      SECURITY_FLAG_STRENGTH_WEAK           = $10000000;
      SECURITY_FLAG_STRENGTH_MEDIUM         = $40000000;
      SECURITY_FLAG_STRENGTH_STRONG         = $20000000;
    
    
    
    // Secure connection error status flags
      WINHTTP_CALLBACK_STATUS_FLAG_CERT_REV_FAILED        = $00000001;
      WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CERT           = $00000002;
      WINHTTP_CALLBACK_STATUS_FLAG_CERT_REVOKED           = $00000004;
      WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CA             = $00000008;
      WINHTTP_CALLBACK_STATUS_FLAG_CERT_CN_INVALID        = $00000010;
      WINHTTP_CALLBACK_STATUS_FLAG_CERT_DATE_INVALID      = $00000020;
      WINHTTP_CALLBACK_STATUS_FLAG_CERT_WRONG_USAGE       = $00000040;
      WINHTTP_CALLBACK_STATUS_FLAG_SECURITY_CHANNEL_ERROR = DWORD($80000000);
    
    
      WINHTTP_FLAG_SECURE_PROTOCOL_SSL2 = $00000008;
      WINHTTP_FLAG_SECURE_PROTOCOL_SSL3 = $00000020;
      WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 = $00000080;
      WINHTTP_FLAG_SECURE_PROTOCOL_ALL  = (WINHTTP_FLAG_SECURE_PROTOCOL_SSL2 or
                                           WINHTTP_FLAG_SECURE_PROTOCOL_SSL3 or
                                           WINHTTP_FLAG_SECURE_PROTOCOL_TLS1);
    
    
    //
    // callback function for WinHttpSetStatusCallback
    //
    type
     {WINHTTP_STATUS_CALLBACK = procedure(
        hInternet: HINTERNET;
        dwContext: DWORD_PTR;
        dwInternetStatus: DWORD;
        lpvStatusInformation: Pointer;
        dwStatusInformationLength: DWORD); stdcall;
    
      TFNWinHttpStatusCallback = WINHTTP_STATUS_CALLBACK;
      PFNWinHttpStatusCallback = ^TFNWinHttpStatusCallback;}
      TFNWinHttpStatusCallback = TFarProc;
    
    function WinHttpSetStatusCallback
    (
       hInternet: HINTERNET;
       lpfnInternetCallback: TFNWinHttpStatusCallback;
       dwNotificationFlags: DWORD;
       dwReserved: DWORD_PTR
    ): TFNWinHttpStatusCallback; stdcall; external Winhttpdll name 'WinHttpSetStatusCallback';
    
    //
    // status manifests for WinHttp status callback
    //
    const
      WINHTTP_CALLBACK_STATUS_RESOLVING_NAME         = $00000001;
      WINHTTP_CALLBACK_STATUS_NAME_RESOLVED          = $00000002;
      WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER   = $00000004;
      WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER    = $00000008;
      WINHTTP_CALLBACK_STATUS_SENDING_REQUEST        = $00000010;
      WINHTTP_CALLBACK_STATUS_REQUEST_SENT           = $00000020;
      WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE     = $00000040;
      WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED      = $00000080;
      WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION     = $00000100;
      WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED      = $00000200;
      WINHTTP_CALLBACK_STATUS_HANDLE_CREATED         = $00000400;
      WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING         = $00000800;
      WINHTTP_CALLBACK_STATUS_DETECTING_PROXY        = $00001000;
      WINHTTP_CALLBACK_STATUS_REDIRECT               = $00004000;
      WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE  = $00008000;
      WINHTTP_CALLBACK_STATUS_SECURE_FAILURE         = $00010000;
      WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE      = $00020000;
      WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE         = $00040000;
      WINHTTP_CALLBACK_STATUS_READ_COMPLETE          = $00080000;
      WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE         = $00100000;
      WINHTTP_CALLBACK_STATUS_REQUEST_ERROR          = $00200000;
      WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE   = $00400000;
    
    
    // API Enums for WINHTTP_CALLBACK_STATUS_REQUEST_ERROR:
      API_RECEIVE_RESPONSE         = (1);
      API_QUERY_DATA_AVAILABLE     = (2);
      API_READ_DATA                = (3);
      API_WRITE_DATA               = (4);
      API_SEND_REQUEST             = (5);
    
    
      WINHTTP_CALLBACK_FLAG_RESOLVE_NAME             = (WINHTTP_CALLBACK_STATUS_RESOLVING_NAME or WINHTTP_CALLBACK_STATUS_NAME_RESOLVED);
      WINHTTP_CALLBACK_FLAG_CONNECT_TO_SERVER        = (WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER or WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER);
      WINHTTP_CALLBACK_FLAG_SEND_REQUEST             = (WINHTTP_CALLBACK_STATUS_SENDING_REQUEST or WINHTTP_CALLBACK_STATUS_REQUEST_SENT);
      WINHTTP_CALLBACK_FLAG_RECEIVE_RESPONSE         = (WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE or WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED);
      WINHTTP_CALLBACK_FLAG_CLOSE_CONNECTION         = (WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION or WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED);
      WINHTTP_CALLBACK_FLAG_HANDLES                  = (WINHTTP_CALLBACK_STATUS_HANDLE_CREATED or WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING);
      WINHTTP_CALLBACK_FLAG_DETECTING_PROXY          = WINHTTP_CALLBACK_STATUS_DETECTING_PROXY;
      WINHTTP_CALLBACK_FLAG_REDIRECT                 = WINHTTP_CALLBACK_STATUS_REDIRECT;
      WINHTTP_CALLBACK_FLAG_INTERMEDIATE_RESPONSE    = WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE;
      WINHTTP_CALLBACK_FLAG_SECURE_FAILURE           = WINHTTP_CALLBACK_STATUS_SECURE_FAILURE;
      WINHTTP_CALLBACK_FLAG_SENDREQUEST_COMPLETE     = WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE;
      WINHTTP_CALLBACK_FLAG_HEADERS_AVAILABLE        = WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE;
      WINHTTP_CALLBACK_FLAG_DATA_AVAILABLE           = WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE;
      WINHTTP_CALLBACK_FLAG_READ_COMPLETE            = WINHTTP_CALLBACK_STATUS_READ_COMPLETE;
      WINHTTP_CALLBACK_FLAG_WRITE_COMPLETE           = WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE;
      WINHTTP_CALLBACK_FLAG_REQUEST_ERROR            = WINHTTP_CALLBACK_STATUS_REQUEST_ERROR;
    
    
      WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS          = (WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE or
                                                        WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE or
                                                        WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE or
                                                        WINHTTP_CALLBACK_STATUS_READ_COMPLETE or
                                                        WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE or
                                                        WINHTTP_CALLBACK_STATUS_REQUEST_ERROR);
      WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS        = DWORD($ffffffff);
    
    //
    // if the following value is returned by WinHttpSetStatusCallback, then
    // probably an invalid (non-code) address was supplied for the callback
    //
    
      WINHTTP_INVALID_STATUS_CALLBACK      = Pointer(-1);
    
    
    //
    // WinHttpQueryHeaders info levels. Generally, there is one info level
    // for each potential RFC822/HTTP/MIME header that an HTTP server
    // may send as part of a request response.
    //
    // The WINHTTP_QUERY_RAW_HEADERS info level is provided for clients
    // that choose to perform their own header parsing.
    //
    
    
      WINHTTP_QUERY_MIME_VERSION               = 0;
      WINHTTP_QUERY_CONTENT_TYPE               = 1;
      WINHTTP_QUERY_CONTENT_TRANSFER_ENCODING  = 2;
      WINHTTP_QUERY_CONTENT_ID                 = 3;
      WINHTTP_QUERY_CONTENT_DESCRIPTION        = 4;
      WINHTTP_QUERY_CONTENT_LENGTH             = 5;
      WINHTTP_QUERY_CONTENT_LANGUAGE           = 6;
      WINHTTP_QUERY_ALLOW                      = 7;
      WINHTTP_QUERY_PUBLIC                     = 8;
      WINHTTP_QUERY_DATE                       = 9;
      WINHTTP_QUERY_EXPIRES                    = 10;
      WINHTTP_QUERY_LAST_MODIFIED              = 11;
      WINHTTP_QUERY_MESSAGE_ID                 = 12;
      WINHTTP_QUERY_URI                        = 13;
      WINHTTP_QUERY_DERIVED_FROM               = 14;
      WINHTTP_QUERY_COST                       = 15;
      WINHTTP_QUERY_LINK                       = 16;
      WINHTTP_QUERY_PRAGMA                     = 17;
      WINHTTP_QUERY_VERSION                    = 18;  // special: part of status line
      WINHTTP_QUERY_STATUS_CODE                = 19;  // special: part of status line
      WINHTTP_QUERY_STATUS_TEXT                = 20;  // special: part of status line
      WINHTTP_QUERY_RAW_HEADERS                = 21;  // special: all headers as ASCIIZ
      WINHTTP_QUERY_RAW_HEADERS_CRLF           = 22;  // special: all headers
      WINHTTP_QUERY_CONNECTION                 = 23;
      WINHTTP_QUERY_ACCEPT                     = 24;
      WINHTTP_QUERY_ACCEPT_CHARSET             = 25;
      WINHTTP_QUERY_ACCEPT_ENCODING            = 26;
      WINHTTP_QUERY_ACCEPT_LANGUAGE            = 27;
      WINHTTP_QUERY_AUTHORIZATION              = 28;
      WINHTTP_QUERY_CONTENT_ENCODING           = 29;
      WINHTTP_QUERY_FORWARDED                  = 30;
      WINHTTP_QUERY_FROM                       = 31;
      WINHTTP_QUERY_IF_MODIFIED_SINCE          = 32;
      WINHTTP_QUERY_LOCATION                   = 33;
      WINHTTP_QUERY_ORIG_URI                   = 34;
      WINHTTP_QUERY_REFERER                    = 35;
      WINHTTP_QUERY_RETRY_AFTER                = 36;
      WINHTTP_QUERY_SERVER                     = 37;
      WINHTTP_QUERY_TITLE                      = 38;
      WINHTTP_QUERY_USER_AGENT                 = 39;
      WINHTTP_QUERY_WWW_AUTHENTICATE           = 40;
      WINHTTP_QUERY_PROXY_AUTHENTICATE         = 41;
      WINHTTP_QUERY_ACCEPT_RANGES              = 42;
      WINHTTP_QUERY_SET_COOKIE                 = 43;
      WINHTTP_QUERY_COOKIE                     = 44;
      WINHTTP_QUERY_REQUEST_METHOD             = 45;  // special: GET/POST etc.
      WINHTTP_QUERY_REFRESH                    = 46;
      WINHTTP_QUERY_CONTENT_DISPOSITION        = 47;
    
    //
    // HTTP 1.1 defined headers
    //
    
      WINHTTP_QUERY_AGE                        = 48;
      WINHTTP_QUERY_CACHE_CONTROL              = 49;
      WINHTTP_QUERY_CONTENT_BASE               = 50;
      WINHTTP_QUERY_CONTENT_LOCATION           = 51;
      WINHTTP_QUERY_CONTENT_MD5                = 52;
      WINHTTP_QUERY_CONTENT_RANGE              = 53;
      WINHTTP_QUERY_ETAG                       = 54;
      WINHTTP_QUERY_HOST                       = 55;
      WINHTTP_QUERY_IF_MATCH                   = 56;
      WINHTTP_QUERY_IF_NONE_MATCH              = 57;
      WINHTTP_QUERY_IF_RANGE                   = 58;
      WINHTTP_QUERY_IF_UNMODIFIED_SINCE        = 59;
      WINHTTP_QUERY_MAX_FORWARDS               = 60;
      WINHTTP_QUERY_PROXY_AUTHORIZATION        = 61;
      WINHTTP_QUERY_RANGE                      = 62;
      WINHTTP_QUERY_TRANSFER_ENCODING          = 63;
      WINHTTP_QUERY_UPGRADE                    = 64;
      WINHTTP_QUERY_VARY                       = 65;
      WINHTTP_QUERY_VIA                        = 66;
      WINHTTP_QUERY_WARNING                    = 67;
      WINHTTP_QUERY_EXPECT                     = 68;
      WINHTTP_QUERY_PROXY_CONNECTION           = 69;
      WINHTTP_QUERY_UNLESS_MODIFIED_SINCE      = 70;
    
    
    
      WINHTTP_QUERY_PROXY_SUPPORT              = 75;
      WINHTTP_QUERY_AUTHENTICATION_INFO        = 76;
      WINHTTP_QUERY_PASSPORT_URLS              = 77;
      WINHTTP_QUERY_PASSPORT_CONFIG            = 78;
    
      WINHTTP_QUERY_MAX                        = 78;
    
    //
    // WINHTTP_QUERY_CUSTOM - if this special value is supplied as the dwInfoLevel
    // parameter of WinHttpQueryHeaders() then the lpBuffer parameter contains the name
    // of the header we are to query
    //
    
      WINHTTP_QUERY_CUSTOM                     = 65535;
    
    //
    // WINHTTP_QUERY_FLAG_REQUEST_HEADERS - if this bit is set in the dwInfoLevel
    // parameter of WinHttpQueryHeaders() then the request headers will be queried for the
    // request information
    //
    
      WINHTTP_QUERY_FLAG_REQUEST_HEADERS       = DWORD($80000000);
    
    //
    // WINHTTP_QUERY_FLAG_SYSTEMTIME - if this bit is set in the dwInfoLevel parameter
    // of WinHttpQueryHeaders() AND the header being queried contains date information,
    // e.g. the "Expires:" header then lpBuffer will contain a SYSTEMTIME structure
    // containing the date and time information converted from the header string
    //
    
      WINHTTP_QUERY_FLAG_SYSTEMTIME            = $40000000;
    
    //
    // WINHTTP_QUERY_FLAG_NUMBER - if this bit is set in the dwInfoLevel parameter of
    // HttpQueryHeader(), then the value of the header will be converted to a number
    // before being returned to the caller, if applicable
    //
    
      WINHTTP_QUERY_FLAG_NUMBER                = $20000000;
    
    
    
    //
    // HTTP Response Status Codes:
    //
    
      HTTP_STATUS_CONTINUE            = 100; // OK to continue with request
      HTTP_STATUS_SWITCH_PROTOCOLS    = 101; // server has switched protocols in upgrade header
    
      HTTP_STATUS_OK                  = 200; // request completed
      HTTP_STATUS_CREATED             = 201; // object created, reason = new URI
      HTTP_STATUS_ACCEPTED            = 202; // async completion (TBS)
      HTTP_STATUS_PARTIAL             = 203; // partial completion
      HTTP_STATUS_NO_CONTENT          = 204; // no info to return
      HTTP_STATUS_RESET_CONTENT       = 205; // request completed, but clear form
      HTTP_STATUS_PARTIAL_CONTENT     = 206; // partial GET fulfilled
      HTTP_STATUS_WEBDAV_MULTI_STATUS = 207; // WebDAV Multi-Status
    
      HTTP_STATUS_AMBIGUOUS           = 300; // server couldn't decide what to return
      HTTP_STATUS_MOVED               = 301; // object permanently moved
      HTTP_STATUS_REDIRECT            = 302; // object temporarily moved
      HTTP_STATUS_REDIRECT_METHOD     = 303; // redirection w/ new access method
      HTTP_STATUS_NOT_MODIFIED        = 304; // if-modified-since was not modified
      HTTP_STATUS_USE_PROXY           = 305; // redirection to proxy, location header specifies proxy to use
      HTTP_STATUS_REDIRECT_KEEP_VERB  = 307; // HTTP/1.1: keep same verb
    
      HTTP_STATUS_BAD_REQUEST         = 400; // invalid syntax
      HTTP_STATUS_DENIED              = 401; // access denied
      HTTP_STATUS_PAYMENT_REQ         = 402; // payment required
      HTTP_STATUS_FORBIDDEN           = 403; // request forbidden
      HTTP_STATUS_NOT_FOUND           = 404; // object not found
      HTTP_STATUS_BAD_METHOD          = 405; // method is not allowed
      HTTP_STATUS_NONE_ACCEPTABLE     = 406; // no response acceptable to client found
      HTTP_STATUS_PROXY_AUTH_REQ      = 407; // proxy authentication required
      HTTP_STATUS_REQUEST_TIMEOUT     = 408; // server timed out waiting for request
      HTTP_STATUS_CONFLICT            = 409; // user should resubmit with more info
      HTTP_STATUS_GONE                = 410; // the resource is no longer available
      HTTP_STATUS_LENGTH_REQUIRED     = 411; // the server refused to accept request w/o a length
      HTTP_STATUS_PRECOND_FAILED      = 412; // precondition given in request failed
      HTTP_STATUS_REQUEST_TOO_LARGE   = 413; // request entity was too large
      HTTP_STATUS_URI_TOO_LONG        = 414; // request URI too long
      HTTP_STATUS_UNSUPPORTED_MEDIA   = 415; // unsupported media type
      HTTP_STATUS_RETRY_WITH          = 449; // retry after doing the appropriate action.
    
      HTTP_STATUS_SERVER_ERROR        = 500; // internal server error
      HTTP_STATUS_NOT_SUPPORTED       = 501; // required not supported
      HTTP_STATUS_BAD_GATEWAY         = 502; // error response received from gateway
      HTTP_STATUS_SERVICE_UNAVAIL     = 503; // temporarily overloaded
      HTTP_STATUS_GATEWAY_TIMEOUT     = 504; // timed out waiting for gateway
      HTTP_STATUS_VERSION_NOT_SUP     = 505; // HTTP version not supported
    
      HTTP_STATUS_FIRST               = HTTP_STATUS_CONTINUE;
      HTTP_STATUS_LAST                = HTTP_STATUS_VERSION_NOT_SUP;
    
    //
    // prototypes
    //
    
    function WinHttpOpenRequest
    (
       hConnect: HINTERNET;
       pwszVerb: LPCWSTR;
       pwszObjectName: LPCWSTR;
       pwszVersion: LPCWSTR;
       pwszReferrer: LPCWSTR;
       ppwszAcceptTypes: LPCWSTR; //LPCWSTR FAR *
       dwFlags: DWORD
    ): HINTERNET;  stdcall; external Winhttpdll name 'WinHttpOpenRequest';
    
    // WinHttpOpenRequest prettifers for optional parameters
    const
      WINHTTP_NO_REFERER            = nil;
      WINHTTP_DEFAULT_ACCEPT_TYPES  = nil;
    
    function WinHttpAddRequestHeaders
    (
       hRequest: HINTERNET;
       pwszHeaders: LPCWSTR;
       dwHeadersLength: DWORD;
       dwModifiers: DWORD
    ): BOOL; stdcall; external Winhttpdll name 'WinHttpAddRequestHeaders';
    
    //
    // values for dwModifiers parameter of WinHttpAddRequestHeaders()
    //
    const
      WINHTTP_ADDREQ_INDEX_MASK      = $0000FFFF;
      WINHTTP_ADDREQ_FLAGS_MASK      = DWORD($FFFF0000);
    
    //
    // WINHTTP_ADDREQ_FLAG_ADD_IF_NEW - the header will only be added if it doesn't
    // already exist
    //
    
      WINHTTP_ADDREQ_FLAG_ADD_IF_NEW = $10000000;
    
    //
    // WINHTTP_ADDREQ_FLAG_ADD - if WINHTTP_ADDREQ_FLAG_REPLACE is set but the header is
    // not found then if this flag is set, the header is added anyway, so long as
    // there is a valid header-value
    //
    
      WINHTTP_ADDREQ_FLAG_ADD        = $20000000;
    
    //
    // WINHTTP_ADDREQ_FLAG_COALESCE - coalesce headers with same name. e.g.
    // "Accept: text/*" and "Accept: audio/*" with this flag results in a single
    // header: "Accept: text/*, audio/*"
    //
    
      WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA     = $40000000;
      WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON = $01000000;
      WINHTTP_ADDREQ_FLAG_COALESCE                = WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA;
    
    //
    // WINHTTP_ADDREQ_FLAG_REPLACE - replaces the specified header. Only one header can
    // be supplied in the buffer. If the header to be replaced is not the first
    // in a list of headers with the same name, then the relative index should be
    // supplied in the low 8 bits of the dwModifiers parameter. If the header-value
    // part is missing, then the header is removed
    //
    
      WINHTTP_ADDREQ_FLAG_REPLACE  = DWORD($80000000);
    
      WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH = 0;
    
    function WinHttpSendRequest
    (
       hRequest: HINTERNET;
       pwszHeaders: LPCWSTR;
       dwHeadersLength: DWORD;
       lpOptional: Pointer;
       dwOptionalLength: DWORD;
       dwTotalLength: DWORD;
       dwContext: DWORD_PTR
    ): BOOL; stdcall; external Winhttpdll name 'WinHttpSendRequest';
    
    // WinHttpSendRequest prettifiers for optional parameters.
    const
      WINHTTP_NO_ADDITIONAL_HEADERS = nil;
      WINHTTP_NO_REQUEST_DATA       = nil;
    
    
    function WinHttpSetCredentials
    (
    
       hRequest: HINTERNET;     // HINTERNET handle returned by WinHttpOpenRequest.
    
    
       AuthTargets: DWORD;      // Only WINHTTP_AUTH_TARGET_SERVER and
                                // WINHTTP_AUTH_TARGET_PROXY are supported
                                // in this version and they are mutually
                                // exclusive
    
       AuthScheme: DWORD;       // must be one of the supported Auth Schemes
                                // returned from WinHttpQueryAuthSchemes()
    
       pwszUserName: LPCWSTR;   // 1) NULL if default creds is to be used, in
                                // which case pszPassword will be ignored
    
       pwszPassword: LPCWSTR;   // 1) "" == Blank Password; 2)Parameter ignored
                                // if pszUserName is NULL; 3) Invalid to pass in
                                // NULL if pszUserName is not NULL
       pAuthParams: Pointer
    ): BOOL; stdcall; external Winhttpdll name 'WinHttpSetCredentials';
    
    
    function WinHttpQueryAuthSchemes
    (
       hRequest: HINTERNET;           // HINTERNET handle returned by WinHttpOpenRequest
       lpdwSupportedSchemes: LPDWORD; // a bitmap of available Authentication Schemes
       lpdwFirstScheme: LPDWORD;      // returns the first auth scheme returned by the server
       pdwAuthTarget: LPDWORD
    ): BOOL; stdcall; external Winhttpdll name 'WinHttpQueryAuthSchemes';
    
    function WinHttpQueryAuthParams(
       hRequest: HINTERNET;        // HINTERNET handle returned by WinHttpOpenRequest
       AuthScheme: DWORD;
       pAuthParams: Pointer        // Scheme-specific Advanced auth parameters
    ): BOOL; stdcall; external Winhttpdll name 'WinHttpQueryAuthParams';
    
    function WinHttpReceiveResponse
    (
       hRequest: HINTERNET;
       lpReserved: Pointer
    ): BOOL; stdcall; external Winhttpdll name 'WinHttpReceiveResponse';
    
    
    
    function WinHttpQueryHeaders
    (
       hRequest: HINTERNET;
       dwInfoLevel: DWORD;
       pwszName: LPCWSTR;
       lpBuffer: Pointer;
       lpdwBufferLength: LPDWORD;
       lpdwIndex: LPDWORD
    ): BOOL; stdcall; external Winhttpdll name 'WinHttpQueryHeaders';
    
    // WinHttpQueryHeaders prettifiers for optional parameters.
    const
      WINHTTP_HEADER_NAME_BY_INDEX         = nil;
      WINHTTP_NO_OUTPUT_BUFFER             = nil;
      WINHTTP_NO_HEADER_INDEX              = nil;
    
    function WinHttpDetectAutoProxyConfigUrl
    (
       dwAutoDetectFlags: DWORD;
       ppwszAutoConfigUrl: PLPWSTR
    ): BOOL; stdcall; external Winhttpdll name 'WinHttpDetectAutoProxyConfigUrl';
    
    function WinHttpGetProxyForUrl
    (
       hSession: HINTERNET;
       lpcwszUrl: LPCWSTR;
       pAutoProxyOptions: PWinHttpAutoProxyOptions;
       pProxyInfo:  PWinHttpProxyInfo
    ): BOOL; stdcall; external Winhttpdll name 'WinHttpGetProxyForUrl';
    
    type
      PWinHttpCurrentUserIEProxyConfig = ^TWinHttpCurrentUserIEProxyConfig;
      WINHTTP_CURRENT_USER_IE_PROXY_CONFIG = record
        fAutoDetect: BOOL;
        lpszAutoConfigUrl: LPWSTR;
        lpszProxy: LPWSTR;
        lpszProxyBypass: LPWSTR;
      end;
      TWinHttpCurrentUserIEProxyConfig = WINHTTP_CURRENT_USER_IE_PROXY_CONFIG;
    
    function WinHttpGetIEProxyConfigForCurrentUser
    (
       pProxyConfig: PWinHttpCurrentUserIEProxyConfig
    ): BOOL; stdcall; external Winhttpdll name 'WinHttpGetIEProxyConfigForCurrentUser';
    
    
    //#if !defined(_WINERROR_)
    
    //
    // WinHttp API error returns
    //
    const
      WINHTTP_ERROR_BASE                    = 12000;
    
      ERROR_WINHTTP_OUT_OF_HANDLES          = (WINHTTP_ERROR_BASE + 1);
      ERROR_WINHTTP_TIMEOUT                 = (WINHTTP_ERROR_BASE + 2);
      ERROR_WINHTTP_INTERNAL_ERROR          = (WINHTTP_ERROR_BASE + 4);
      ERROR_WINHTTP_INVALID_URL             = (WINHTTP_ERROR_BASE + 5);
      ERROR_WINHTTP_UNRECOGNIZED_SCHEME     = (WINHTTP_ERROR_BASE + 6);
      ERROR_WINHTTP_NAME_NOT_RESOLVED       = (WINHTTP_ERROR_BASE + 7);
      ERROR_WINHTTP_INVALID_OPTION          = (WINHTTP_ERROR_BASE + 9);
      ERROR_WINHTTP_OPTION_NOT_SETTABLE     = (WINHTTP_ERROR_BASE + 11);
      ERROR_WINHTTP_SHUTDOWN                = (WINHTTP_ERROR_BASE + 12);
    
    
      ERROR_WINHTTP_LOGIN_FAILURE           = (WINHTTP_ERROR_BASE + 15);
      ERROR_WINHTTP_OPERATION_CANCELLED     = (WINHTTP_ERROR_BASE + 17);
      ERROR_WINHTTP_INCORRECT_HANDLE_TYPE   = (WINHTTP_ERROR_BASE + 18);
      ERROR_WINHTTP_INCORRECT_HANDLE_STATE  = (WINHTTP_ERROR_BASE + 19);
      ERROR_WINHTTP_CANNOT_CONNECT          = (WINHTTP_ERROR_BASE + 29);
      ERROR_WINHTTP_CONNECTION_ERROR        = (WINHTTP_ERROR_BASE + 30);
      ERROR_WINHTTP_RESEND_REQUEST          = (WINHTTP_ERROR_BASE + 32);
    
      ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED = (WINHTTP_ERROR_BASE + 44);
    
    //
    // WinHttpRequest Component errors
    //
      ERROR_WINHTTP_CANNOT_CALL_BEFORE_OPEN	= (WINHTTP_ERROR_BASE + 100);
      ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND	= (WINHTTP_ERROR_BASE + 101);
      ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND	= (WINHTTP_ERROR_BASE + 102);
      ERROR_WINHTTP_CANNOT_CALL_AFTER_OPEN  = (WINHTTP_ERROR_BASE + 103);
    
    
    //
    // HTTP API errors
    //
    
      ERROR_WINHTTP_HEADER_NOT_FOUND           = (WINHTTP_ERROR_BASE + 150);
      ERROR_WINHTTP_INVALID_SERVER_RESPONSE    = (WINHTTP_ERROR_BASE + 152);
      ERROR_WINHTTP_INVALID_HEADER             = (WINHTTP_ERROR_BASE + 153);
      ERROR_WINHTTP_INVALID_QUERY_REQUEST      = (WINHTTP_ERROR_BASE + 154);
      ERROR_WINHTTP_HEADER_ALREADY_EXISTS      = (WINHTTP_ERROR_BASE + 155);
      ERROR_WINHTTP_REDIRECT_FAILED            = (WINHTTP_ERROR_BASE + 156);
    
    
    
    //
    // additional WinHttp API error codes
    //
    
    //
    // additional WinHttp API error codes
    //
      ERROR_WINHTTP_AUTO_PROXY_SERVICE_ERROR  = (WINHTTP_ERROR_BASE + 178);
      ERROR_WINHTTP_BAD_AUTO_PROXY_SCRIPT     = (WINHTTP_ERROR_BASE + 166);
      ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT = (WINHTTP_ERROR_BASE + 167);
    
      ERROR_WINHTTP_NOT_INITIALIZED         = (WINHTTP_ERROR_BASE + 172);
      ERROR_WINHTTP_SECURE_FAILURE          = (WINHTTP_ERROR_BASE + 175);
    
    
    //
    // Certificate security errors. These are raised only by the WinHttpRequest
    // component. The WinHTTP Win32 API will return ERROR_WINHTTP_SECURE_FAILE and
    // provide additional information via the WINHTTP_CALLBACK_STATUS_SECURE_FAILURE
    // callback notification.
    //
      ERROR_WINHTTP_SECURE_CERT_DATE_INVALID  = (WINHTTP_ERROR_BASE + 37);
      ERROR_WINHTTP_SECURE_CERT_CN_INVALID    = (WINHTTP_ERROR_BASE + 38);
      ERROR_WINHTTP_SECURE_INVALID_CA         = (WINHTTP_ERROR_BASE + 45);
      ERROR_WINHTTP_SECURE_CERT_REV_FAILED    = (WINHTTP_ERROR_BASE + 57);
      ERROR_WINHTTP_SECURE_CHANNEL_ERROR      = (WINHTTP_ERROR_BASE + 157);
      ERROR_WINHTTP_SECURE_INVALID_CERT       = (WINHTTP_ERROR_BASE + 169);
      ERROR_WINHTTP_SECURE_CERT_REVOKED       = (WINHTTP_ERROR_BASE + 170);
      ERROR_WINHTTP_SECURE_CERT_WRONG_USAGE   = (WINHTTP_ERROR_BASE + 179);
    
    
      ERROR_WINHTTP_AUTODETECTION_FAILED                  = (WINHTTP_ERROR_BASE + 180);
      ERROR_WINHTTP_HEADER_COUNT_EXCEEDED                 = (WINHTTP_ERROR_BASE + 181);
      ERROR_WINHTTP_HEADER_SIZE_OVERFLOW                  = (WINHTTP_ERROR_BASE + 182);
      ERROR_WINHTTP_CHUNKED_ENCODING_HEADER_SIZE_OVERFLOW = (WINHTTP_ERROR_BASE + 183);
      ERROR_WINHTTP_RESPONSE_DRAIN_OVERFLOW               = (WINHTTP_ERROR_BASE + 184);
      ERROR_WINHTTP_CLIENT_CERT_NO_PRIVATE_KEY            = (WINHTTP_ERROR_BASE + 185);
      ERROR_WINHTTP_CLIENT_CERT_NO_ACCESS_PRIVATE_KEY     = (WINHTTP_ERROR_BASE + 186);
    
      WINHTTP_ERROR_LAST                                  = (WINHTTP_ERROR_BASE + 186);
    
    implementation
    
    end.
    
    winhttp.pas (44,059 bytes)
  • winhttp.2.pas (26,676 bytes)
    unit winhttp;
    
    interface
    
    uses
      windows;
    
    {$ifdef win64}
       {$packrecords 8}
     {$else}
       {$packrecords 4}
     {$endif}
    
    
    const
      External_library='winhttp.dll'; {Setup as you need}
    
    
      {
       * Copyright (C) 2007 Francois Gouget
       *
       * This library is free software; you can redistribute it and/or
       * modify it under the terms of the GNU Lesser General Public
       * License as published by the Free Software Foundation; either
       * version 2.1 of the License, or (at your option) any later version.
       *
       * This library is distributed in the hope that it will be useful,
       * but WITHOUT ANY WARRANTY; without even the implied warranty of
       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       * Lesser General Public License for more details.
       *
       * You should have received a copy of the GNU Lesser General Public
       * License along with this library; if not, write to the Free Software
       * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
      }
    
    
    
    type
      PHINTERNET = ^HINTERNET;
      HINTERNET = LPVOID;
    
      PLPHINTERNET = ^LPHINTERNET;
      LPHINTERNET = PHINTERNET;
    
    const
      INTERNET_DEFAULT_PORT = 0;
      INTERNET_DEFAULT_HTTP_PORT = 80;
      INTERNET_DEFAULT_HTTPS_PORT = 443;
    
    type
      PINTERNET_PORT = ^INTERNET_PORT;
      INTERNET_PORT = WORD;
    
      PLPINTERNET_PORT = ^LPINTERNET_PORT;
      LPINTERNET_PORT = PINTERNET_PORT;
    
    const
      INTERNET_SCHEME_HTTP = 1;
      INTERNET_SCHEME_HTTPS = 2;
    
    type
      PINTERNET_SCHEME = ^INTERNET_SCHEME;
      INTERNET_SCHEME = longint;
      LPINTERNET_SCHEME = PINTERNET_SCHEME;
      PLPINTERNET_SCHEME = ^LPINTERNET_SCHEME;
    
    const
      ICU_ESCAPE = $80000000;
    { flags for WinHttpOpen  }
      WINHTTP_FLAG_ASYNC = $10000000;
    { flags for WinHttpOpenRequest  }
      WINHTTP_FLAG_ESCAPE_PERCENT = $00000004;
      WINHTTP_FLAG_NULL_CODEPAGE = $00000008;
      WINHTTP_FLAG_ESCAPE_DISABLE = $00000040;
      WINHTTP_FLAG_ESCAPE_DISABLE_QUERY = $00000080;
      WINHTTP_FLAG_BYPASS_PROXY_CACHE = $00000100;
      WINHTTP_FLAG_REFRESH = WINHTTP_FLAG_BYPASS_PROXY_CACHE;
      WINHTTP_FLAG_SECURE = $00800000;
      WINHTTP_ACCESS_TYPE_DEFAULT_PROXY = 0;
      WINHTTP_ACCESS_TYPE_NO_PROXY = 1;
      WINHTTP_ACCESS_TYPE_NAMED_PROXY = 3;
      WINHTTP_NO_PROXY_NAME = nil;
      WINHTTP_NO_PROXY_BYPASS = nil;
      WINHTTP_NO_REFERER = nil;
      WINHTTP_DEFAULT_ACCEPT_TYPES = nil;
      WINHTTP_NO_ADDITIONAL_HEADERS = nil;
      WINHTTP_NO_REQUEST_DATA = nil;
      WINHTTP_HEADER_NAME_BY_INDEX = nil;
      WINHTTP_NO_OUTPUT_BUFFER = nil;
      WINHTTP_NO_HEADER_INDEX = nil;
      WINHTTP_ADDREQ_INDEX_MASK = $0000FFFF;
      WINHTTP_ADDREQ_FLAGS_MASK = $FFFF0000;
      WINHTTP_ADDREQ_FLAG_ADD_IF_NEW = $10000000;
      WINHTTP_ADDREQ_FLAG_ADD = $20000000;
      WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA = $40000000;
      WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON = $01000000;
      WINHTTP_ADDREQ_FLAG_COALESCE = WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA;
      WINHTTP_ADDREQ_FLAG_REPLACE = $80000000;
      WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH = 0;
    { flags for WinHttpSet/QueryOptions  }
      WINHTTP_OPTION_CALLBACK = 1;
      WINHTTP_FIRST_OPTION = WINHTTP_OPTION_CALLBACK;
      WINHTTP_OPTION_RESOLVE_TIMEOUT = 2;
      WINHTTP_OPTION_CONNECT_TIMEOUT = 3;
      WINHTTP_OPTION_CONNECT_RETRIES = 4;
      WINHTTP_OPTION_SEND_TIMEOUT = 5;
      WINHTTP_OPTION_RECEIVE_TIMEOUT = 6;
      WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT = 7;
      WINHTTP_OPTION_HANDLE_TYPE = 9;
      WINHTTP_OPTION_READ_BUFFER_SIZE = 12;
      WINHTTP_OPTION_WRITE_BUFFER_SIZE = 13;
      WINHTTP_OPTION_PARENT_HANDLE = 21;
      WINHTTP_OPTION_EXTENDED_ERROR = 24;
      WINHTTP_OPTION_SECURITY_FLAGS = 31;
      WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT = 32;
      WINHTTP_OPTION_URL = 34;
      WINHTTP_OPTION_SECURITY_KEY_BITNESS = 36;
      WINHTTP_OPTION_PROXY = 38;
      WINHTTP_OPTION_USER_AGENT = 41;
      WINHTTP_OPTION_CONTEXT_VALUE = 45;
      WINHTTP_OPTION_CLIENT_CERT_CONTEXT = 47;
      WINHTTP_OPTION_REQUEST_PRIORITY = 58;
      WINHTTP_OPTION_HTTP_VERSION = 59;
      WINHTTP_OPTION_DISABLE_FEATURE = 63;
      WINHTTP_OPTION_CODEPAGE = 68;
      WINHTTP_OPTION_MAX_CONNS_PER_SERVER = 73;
      WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER = 74;
      WINHTTP_OPTION_AUTOLOGON_POLICY = 77;
      WINHTTP_OPTION_SERVER_CERT_CONTEXT = 78;
      WINHTTP_OPTION_ENABLE_FEATURE = 79;
      WINHTTP_OPTION_WORKER_THREAD_COUNT = 80;
      WINHTTP_OPTION_PASSPORT_COBRANDING_TEXT = 81;
      WINHTTP_OPTION_PASSPORT_COBRANDING_URL = 82;
      WINHTTP_OPTION_CONFIGURE_PASSPORT_AUTH = 83;
      WINHTTP_OPTION_SECURE_PROTOCOLS = 84;
      WINHTTP_OPTION_ENABLETRACING = 85;
      WINHTTP_OPTION_PASSPORT_SIGN_OUT = 86;
      WINHTTP_OPTION_PASSPORT_RETURN_URL = 87;
      WINHTTP_OPTION_REDIRECT_POLICY = 88;
      WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS = 89;
      WINHTTP_OPTION_MAX_HTTP_STATUS_CONTINUE = 90;
      WINHTTP_OPTION_MAX_RESPONSE_HEADER_SIZE = 91;
      WINHTTP_OPTION_MAX_RESPONSE_DRAIN_SIZE = 92;
      WINHTTP_OPTION_CONNECTION_INFO = 93;
      WINHTTP_OPTION_CLIENT_CERT_ISSUER_LIST = 94;
      WINHTTP_OPTION_SPN = 96;
      WINHTTP_OPTION_GLOBAL_PROXY_CREDS = 97;
      WINHTTP_OPTION_GLOBAL_SERVER_CREDS = 98;
      WINHTTP_OPTION_UNLOAD_NOTIFY_EVENT = 99;
      WINHTTP_OPTION_REJECT_USERPWD_IN_URL = 100;
      WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS = 101;
      WINHTTP_LAST_OPTION = WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS;
      WINHTTP_OPTION_USERNAME = $1000;
      WINHTTP_OPTION_PASSWORD = $1001;
      WINHTTP_OPTION_PROXY_USERNAME = $1002;
      WINHTTP_OPTION_PROXY_PASSWORD = $1003;
      WINHTTP_CONNS_PER_SERVER_UNLIMITED = $FFFFFFFF;
      WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM = 0;
      WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW = 1;
      WINHTTP_AUTOLOGON_SECURITY_LEVEL_HIGH = 2;
      WINHTTP_AUTOLOGON_SECURITY_LEVEL_DEFAULT = WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM;
      WINHTTP_OPTION_REDIRECT_POLICY_NEVER = 0;
      WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP = 1;
      WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS = 2;
      WINHTTP_OPTION_REDIRECT_POLICY_LAST = WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS;
      WINHTTP_OPTION_REDIRECT_POLICY_DEFAULT = WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP;
      WINHTTP_DISABLE_PASSPORT_AUTH = $00000000;
      WINHTTP_ENABLE_PASSPORT_AUTH = $10000000;
      WINHTTP_DISABLE_PASSPORT_KEYRING = $20000000;
      WINHTTP_ENABLE_PASSPORT_KEYRING = $40000000;
      WINHTTP_DISABLE_COOKIES = $00000001;
      WINHTTP_DISABLE_REDIRECTS = $00000002;
      WINHTTP_DISABLE_AUTHENTICATION = $00000004;
      WINHTTP_DISABLE_KEEP_ALIVE = $00000008;
      WINHTTP_ENABLE_SSL_REVOCATION = $00000001;
      WINHTTP_ENABLE_SSL_REVERT_IMPERSONATION = $00000002;
      WINHTTP_DISABLE_SPN_SERVER_PORT = $00000000;
      WINHTTP_ENABLE_SPN_SERVER_PORT = $00000001;
      WINHTTP_OPTION_SPN_MASK = WINHTTP_ENABLE_SPN_SERVER_PORT;
    
      { WinHTTP error codes  }
      WINHTTP_ERROR_BASE = 12000;
      ERROR_WINHTTP_OUT_OF_HANDLES = WINHTTP_ERROR_BASE+1;
      ERROR_WINHTTP_TIMEOUT = WINHTTP_ERROR_BASE+2;
      ERROR_WINHTTP_INTERNAL_ERROR = WINHTTP_ERROR_BASE+4;
      ERROR_WINHTTP_INVALID_URL = WINHTTP_ERROR_BASE+5;
      ERROR_WINHTTP_UNRECOGNIZED_SCHEME = WINHTTP_ERROR_BASE+6;
      ERROR_WINHTTP_NAME_NOT_RESOLVED = WINHTTP_ERROR_BASE+7;
      ERROR_WINHTTP_INVALID_OPTION = WINHTTP_ERROR_BASE+9;
      ERROR_WINHTTP_OPTION_NOT_SETTABLE = WINHTTP_ERROR_BASE+11;
      ERROR_WINHTTP_SHUTDOWN = WINHTTP_ERROR_BASE+12;
      ERROR_WINHTTP_LOGIN_FAILURE = WINHTTP_ERROR_BASE+15;
      ERROR_WINHTTP_OPERATION_CANCELLED = WINHTTP_ERROR_BASE+17;
      ERROR_WINHTTP_INCORRECT_HANDLE_TYPE = WINHTTP_ERROR_BASE+18;
      ERROR_WINHTTP_INCORRECT_HANDLE_STATE = WINHTTP_ERROR_BASE+19;
      ERROR_WINHTTP_CANNOT_CONNECT = WINHTTP_ERROR_BASE+29;
      ERROR_WINHTTP_CONNECTION_ERROR = WINHTTP_ERROR_BASE+30;
      ERROR_WINHTTP_RESEND_REQUEST = WINHTTP_ERROR_BASE+32;
      ERROR_WINHTTP_SECURE_CERT_DATE_INVALID = WINHTTP_ERROR_BASE+37;
      ERROR_WINHTTP_SECURE_CERT_CN_INVALID = WINHTTP_ERROR_BASE+38;
      ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED = WINHTTP_ERROR_BASE+44;
      ERROR_WINHTTP_SECURE_INVALID_CA = WINHTTP_ERROR_BASE+45;
      ERROR_WINHTTP_SECURE_CERT_REV_FAILED = WINHTTP_ERROR_BASE+57;
      ERROR_WINHTTP_CANNOT_CALL_BEFORE_OPEN = WINHTTP_ERROR_BASE+100;
      ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND = WINHTTP_ERROR_BASE+101;
      ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND = WINHTTP_ERROR_BASE+102;
      ERROR_WINHTTP_CANNOT_CALL_AFTER_OPEN = WINHTTP_ERROR_BASE+103;
      ERROR_WINHTTP_HEADER_NOT_FOUND = WINHTTP_ERROR_BASE+150;
      ERROR_WINHTTP_INVALID_SERVER_RESPONSE = WINHTTP_ERROR_BASE+152;
      ERROR_WINHTTP_INVALID_HEADER = WINHTTP_ERROR_BASE+153;
      ERROR_WINHTTP_INVALID_QUERY_REQUEST = WINHTTP_ERROR_BASE+154;
      ERROR_WINHTTP_HEADER_ALREADY_EXISTS = WINHTTP_ERROR_BASE+155;
      ERROR_WINHTTP_REDIRECT_FAILED = WINHTTP_ERROR_BASE+156;
      ERROR_WINHTTP_SECURE_CHANNEL_ERROR = WINHTTP_ERROR_BASE+157;
      ERROR_WINHTTP_BAD_AUTO_PROXY_SCRIPT = WINHTTP_ERROR_BASE+166;
      ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT = WINHTTP_ERROR_BASE+167;
      ERROR_WINHTTP_SECURE_INVALID_CERT = WINHTTP_ERROR_BASE+169;
      ERROR_WINHTTP_SECURE_CERT_REVOKED = WINHTTP_ERROR_BASE+170;
      ERROR_WINHTTP_NOT_INITIALIZED = WINHTTP_ERROR_BASE+172;
      ERROR_WINHTTP_SECURE_FAILURE = WINHTTP_ERROR_BASE+175;
      ERROR_WINHTTP_AUTO_PROXY_SERVICE_ERROR = WINHTTP_ERROR_BASE+178;
      ERROR_WINHTTP_SECURE_CERT_WRONG_USAGE = WINHTTP_ERROR_BASE+179;
      ERROR_WINHTTP_AUTODETECTION_FAILED = WINHTTP_ERROR_BASE+180;
      ERROR_WINHTTP_HEADER_COUNT_EXCEEDED = WINHTTP_ERROR_BASE+181;
      ERROR_WINHTTP_HEADER_SIZE_OVERFLOW = WINHTTP_ERROR_BASE+182;
      ERROR_WINHTTP_CHUNKED_ENCODING_HEADER_SIZE_OVERFLOW = WINHTTP_ERROR_BASE+183;
      ERROR_WINHTTP_RESPONSE_DRAIN_OVERFLOW = WINHTTP_ERROR_BASE+184;
      ERROR_WINHTTP_CLIENT_CERT_NO_PRIVATE_KEY = WINHTTP_ERROR_BASE+185;
      ERROR_WINHTTP_CLIENT_CERT_NO_ACCESS_PRIVATE_KEY = WINHTTP_ERROR_BASE+186;
      WINHTTP_ERROR_LAST = WINHTTP_ERROR_BASE+186;
    { WinHttp status codes  }
      HTTP_STATUS_CONTINUE = 100;
      HTTP_STATUS_SWITCH_PROTOCOLS = 101;
      HTTP_STATUS_OK = 200;
      HTTP_STATUS_CREATED = 201;
      HTTP_STATUS_ACCEPTED = 202;
      HTTP_STATUS_PARTIAL = 203;
      HTTP_STATUS_NO_CONTENT = 204;
      HTTP_STATUS_RESET_CONTENT = 205;
      HTTP_STATUS_PARTIAL_CONTENT = 206;
      HTTP_STATUS_WEBDAV_MULTI_STATUS = 207;
      HTTP_STATUS_AMBIGUOUS = 300;
      HTTP_STATUS_MOVED = 301;
      HTTP_STATUS_REDIRECT = 302;
      HTTP_STATUS_REDIRECT_METHOD = 303;
      HTTP_STATUS_NOT_MODIFIED = 304;
      HTTP_STATUS_USE_PROXY = 305;
      HTTP_STATUS_REDIRECT_KEEP_VERB = 307;
      HTTP_STATUS_BAD_REQUEST = 400;
      HTTP_STATUS_DENIED = 401;
      HTTP_STATUS_PAYMENT_REQ = 402;
      HTTP_STATUS_FORBIDDEN = 403;
      HTTP_STATUS_NOT_FOUND = 404;
      HTTP_STATUS_BAD_METHOD = 405;
      HTTP_STATUS_NONE_ACCEPTABLE = 406;
      HTTP_STATUS_PROXY_AUTH_REQ = 407;
      HTTP_STATUS_REQUEST_TIMEOUT = 408;
      HTTP_STATUS_CONFLICT = 409;
      HTTP_STATUS_GONE = 410;
      HTTP_STATUS_LENGTH_REQUIRED = 411;
      HTTP_STATUS_PRECOND_FAILED = 412;
      HTTP_STATUS_REQUEST_TOO_LARGE = 413;
      HTTP_STATUS_URI_TOO_LONG = 414;
      HTTP_STATUS_UNSUPPORTED_MEDIA = 415;
      HTTP_STATUS_RETRY_WITH = 449;
      HTTP_STATUS_SERVER_ERROR = 500;
      HTTP_STATUS_NOT_SUPPORTED = 501;
      HTTP_STATUS_BAD_GATEWAY = 502;
      HTTP_STATUS_SERVICE_UNAVAIL = 503;
      HTTP_STATUS_GATEWAY_TIMEOUT = 504;
      HTTP_STATUS_VERSION_NOT_SUP = 505;
      HTTP_STATUS_FIRST = HTTP_STATUS_CONTINUE;
      HTTP_STATUS_LAST = HTTP_STATUS_VERSION_NOT_SUP;
      SECURITY_FLAG_IGNORE_UNKNOWN_CA = $00000100;
      SECURITY_FLAG_IGNORE_CERT_DATE_INVALID = $00002000;
      SECURITY_FLAG_IGNORE_CERT_CN_INVALID = $00001000;
      SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE = $00000200;
      SECURITY_FLAG_SECURE = $00000001;
      SECURITY_FLAG_STRENGTH_WEAK = $10000000;
      SECURITY_FLAG_STRENGTH_MEDIUM = $40000000;
      SECURITY_FLAG_STRENGTH_STRONG = $20000000;
      ICU_NO_ENCODE = $20000000;
      ICU_DECODE = $10000000;
      ICU_NO_META = $08000000;
      ICU_ENCODE_SPACES_ONLY = $04000000;
      ICU_BROWSER_MODE = $02000000;
      ICU_ENCODE_PERCENT = $00001000;
    { Query flags  }
      WINHTTP_QUERY_MIME_VERSION = 0;
      WINHTTP_QUERY_CONTENT_TYPE = 1;
      WINHTTP_QUERY_CONTENT_TRANSFER_ENCODING = 2;
      WINHTTP_QUERY_CONTENT_ID = 3;
      WINHTTP_QUERY_CONTENT_DESCRIPTION = 4;
      WINHTTP_QUERY_CONTENT_LENGTH = 5;
      WINHTTP_QUERY_CONTENT_LANGUAGE = 6;
      WINHTTP_QUERY_ALLOW = 7;
      WINHTTP_QUERY_PUBLIC = 8;
      WINHTTP_QUERY_DATE = 9;
      WINHTTP_QUERY_EXPIRES = 10;
      WINHTTP_QUERY_LAST_MODIFIED = 11;
      WINHTTP_QUERY_MESSAGE_ID = 12;
      WINHTTP_QUERY_URI = 13;
      WINHTTP_QUERY_DERIVED_FROM = 14;
      WINHTTP_QUERY_COST = 15;
      WINHTTP_QUERY_LINK = 16;
      WINHTTP_QUERY_PRAGMA = 17;
      WINHTTP_QUERY_VERSION = 18;
      WINHTTP_QUERY_STATUS_CODE = 19;
      WINHTTP_QUERY_STATUS_TEXT = 20;
      WINHTTP_QUERY_RAW_HEADERS = 21;
      WINHTTP_QUERY_RAW_HEADERS_CRLF = 22;
      WINHTTP_QUERY_CONNECTION = 23;
      WINHTTP_QUERY_ACCEPT = 24;
      WINHTTP_QUERY_ACCEPT_CHARSET = 25;
      WINHTTP_QUERY_ACCEPT_ENCODING = 26;
      WINHTTP_QUERY_ACCEPT_LANGUAGE = 27;
      WINHTTP_QUERY_AUTHORIZATION = 28;
      WINHTTP_QUERY_CONTENT_ENCODING = 29;
      WINHTTP_QUERY_FORWARDED = 30;
      WINHTTP_QUERY_FROM = 31;
      WINHTTP_QUERY_IF_MODIFIED_SINCE = 32;
      WINHTTP_QUERY_LOCATION = 33;
      WINHTTP_QUERY_ORIG_URI = 34;
      WINHTTP_QUERY_REFERER = 35;
      WINHTTP_QUERY_RETRY_AFTER = 36;
      WINHTTP_QUERY_SERVER = 37;
      WINHTTP_QUERY_TITLE = 38;
      WINHTTP_QUERY_USER_AGENT = 39;
      WINHTTP_QUERY_WWW_AUTHENTICATE = 40;
      WINHTTP_QUERY_PROXY_AUTHENTICATE = 41;
      WINHTTP_QUERY_ACCEPT_RANGES = 42;
      WINHTTP_QUERY_SET_COOKIE = 43;
      WINHTTP_QUERY_COOKIE = 44;
      WINHTTP_QUERY_REQUEST_METHOD = 45;
      WINHTTP_QUERY_REFRESH = 46;
      WINHTTP_QUERY_CONTENT_DISPOSITION = 47;
      WINHTTP_QUERY_AGE = 48;
      WINHTTP_QUERY_CACHE_CONTROL = 49;
      WINHTTP_QUERY_CONTENT_BASE = 50;
      WINHTTP_QUERY_CONTENT_LOCATION = 51;
      WINHTTP_QUERY_CONTENT_MD5 = 52;
      WINHTTP_QUERY_CONTENT_RANGE = 53;
      WINHTTP_QUERY_ETAG = 54;
      WINHTTP_QUERY_HOST = 55;
      WINHTTP_QUERY_IF_MATCH = 56;
      WINHTTP_QUERY_IF_NONE_MATCH = 57;
      WINHTTP_QUERY_IF_RANGE = 58;
      WINHTTP_QUERY_IF_UNMODIFIED_SINCE = 59;
      WINHTTP_QUERY_MAX_FORWARDS = 60;
      WINHTTP_QUERY_PROXY_AUTHORIZATION = 61;
      WINHTTP_QUERY_RANGE = 62;
      WINHTTP_QUERY_TRANSFER_ENCODING = 63;
      WINHTTP_QUERY_UPGRADE = 64;
      WINHTTP_QUERY_VARY = 65;
      WINHTTP_QUERY_VIA = 66;
      WINHTTP_QUERY_WARNING = 67;
      WINHTTP_QUERY_EXPECT = 68;
      WINHTTP_QUERY_PROXY_CONNECTION = 69;
      WINHTTP_QUERY_UNLESS_MODIFIED_SINCE = 70;
      WINHTTP_QUERY_PROXY_SUPPORT = 75;
      WINHTTP_QUERY_AUTHENTICATION_INFO = 76;
      WINHTTP_QUERY_PASSPORT_URLS = 77;
      WINHTTP_QUERY_PASSPORT_CONFIG = 78;
      WINHTTP_QUERY_MAX = 78;
      WINHTTP_QUERY_CUSTOM = 65535;
      WINHTTP_QUERY_FLAG_REQUEST_HEADERS = $80000000;
      WINHTTP_QUERY_FLAG_SYSTEMTIME = $40000000;
      WINHTTP_QUERY_FLAG_NUMBER = $20000000;
    { Callback options  }
      WINHTTP_CALLBACK_STATUS_RESOLVING_NAME = $00000001;
      WINHTTP_CALLBACK_STATUS_NAME_RESOLVED = $00000002;
      WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER = $00000004;
      WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER = $00000008;
      WINHTTP_CALLBACK_STATUS_SENDING_REQUEST = $00000010;
      WINHTTP_CALLBACK_STATUS_REQUEST_SENT = $00000020;
      WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE = $00000040;
      WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED = $00000080;
      WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION = $00000100;
      WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED = $00000200;
      WINHTTP_CALLBACK_STATUS_HANDLE_CREATED = $00000400;
      WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING = $00000800;
      WINHTTP_CALLBACK_STATUS_DETECTING_PROXY = $00001000;
      WINHTTP_CALLBACK_STATUS_REDIRECT = $00004000;
      WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE = $00008000;
      WINHTTP_CALLBACK_STATUS_SECURE_FAILURE = $00010000;
      WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE = $00020000;
      WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE = $00040000;
      WINHTTP_CALLBACK_STATUS_READ_COMPLETE = $00080000;
      WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE = $00100000;
      WINHTTP_CALLBACK_STATUS_REQUEST_ERROR = $00200000;
      WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE = $00400000;
      WINHTTP_CALLBACK_FLAG_RESOLVE_NAME = WINHTTP_CALLBACK_STATUS_RESOLVING_NAME or WINHTTP_CALLBACK_STATUS_NAME_RESOLVED;
      WINHTTP_CALLBACK_FLAG_CONNECT_TO_SERVER = WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER or WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER;
      WINHTTP_CALLBACK_FLAG_SEND_REQUEST = WINHTTP_CALLBACK_STATUS_SENDING_REQUEST or WINHTTP_CALLBACK_STATUS_REQUEST_SENT;
      WINHTTP_CALLBACK_FLAG_RECEIVE_RESPONSE = WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE or WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED;
      WINHTTP_CALLBACK_FLAG_CLOSE_CONNECTION = WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION or WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED;
      WINHTTP_CALLBACK_FLAG_HANDLES = WINHTTP_CALLBACK_STATUS_HANDLE_CREATED or WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING;
      WINHTTP_CALLBACK_FLAG_DETECTING_PROXY = WINHTTP_CALLBACK_STATUS_DETECTING_PROXY;
      WINHTTP_CALLBACK_FLAG_REDIRECT = WINHTTP_CALLBACK_STATUS_REDIRECT;
      WINHTTP_CALLBACK_FLAG_INTERMEDIATE_RESPONSE = WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE;
      WINHTTP_CALLBACK_FLAG_SECURE_FAILURE = WINHTTP_CALLBACK_STATUS_SECURE_FAILURE;
      WINHTTP_CALLBACK_FLAG_SENDREQUEST_COMPLETE = WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE;
      WINHTTP_CALLBACK_FLAG_HEADERS_AVAILABLE = WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE;
      WINHTTP_CALLBACK_FLAG_DATA_AVAILABLE = WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE;
      WINHTTP_CALLBACK_FLAG_READ_COMPLETE = WINHTTP_CALLBACK_STATUS_READ_COMPLETE;
      WINHTTP_CALLBACK_FLAG_WRITE_COMPLETE = WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE;
      WINHTTP_CALLBACK_FLAG_REQUEST_ERROR = WINHTTP_CALLBACK_STATUS_REQUEST_ERROR;
      WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS = ((((WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE or WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE) or WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE) or WINHTTP_CALLBACK_STATUS_READ_COMPLETE) or WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE) or WINHTTP_CALLBACK_STATUS_REQUEST_ERROR;
      WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS = $ffffffff;
    
    
    const
      API_RECEIVE_RESPONSE = 1;
      API_QUERY_DATA_AVAILABLE = 2;
      API_READ_DATA = 3;
      API_WRITE_DATA = 4;
      API_SEND_REQUEST = 5;
      WINHTTP_HANDLE_TYPE_SESSION = 1;
      WINHTTP_HANDLE_TYPE_CONNECT = 2;
      WINHTTP_HANDLE_TYPE_REQUEST = 3;
      WINHTTP_CALLBACK_STATUS_FLAG_CERT_REV_FAILED = $00000001;
      WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CERT = $00000002;
      WINHTTP_CALLBACK_STATUS_FLAG_CERT_REVOKED = $00000004;
      WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CA = $00000008;
      WINHTTP_CALLBACK_STATUS_FLAG_CERT_CN_INVALID = $00000010;
      WINHTTP_CALLBACK_STATUS_FLAG_CERT_DATE_INVALID = $00000020;
      WINHTTP_CALLBACK_STATUS_FLAG_CERT_WRONG_USAGE = $00000040;
      WINHTTP_CALLBACK_STATUS_FLAG_SECURITY_CHANNEL_ERROR = $80000000;
      WINHTTP_FLAG_SECURE_PROTOCOL_SSL2 = $00000008;
      WINHTTP_FLAG_SECURE_PROTOCOL_SSL3 = $00000020;
      WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 = $00000080;
      WINHTTP_FLAG_SECURE_PROTOCOL_ALL = (WINHTTP_FLAG_SECURE_PROTOCOL_SSL2 or WINHTTP_FLAG_SECURE_PROTOCOL_SSL3) or WINHTTP_FLAG_SECURE_PROTOCOL_TLS1;
      WINHTTP_AUTH_SCHEME_BASIC = $00000001;
      WINHTTP_AUTH_SCHEME_NTLM = $00000002;
      WINHTTP_AUTH_SCHEME_PASSPORT = $00000004;
      WINHTTP_AUTH_SCHEME_DIGEST = $00000008;
      WINHTTP_AUTH_SCHEME_NEGOTIATE = $00000010;
      WINHTTP_AUTH_TARGET_SERVER = $00000000;
      WINHTTP_AUTH_TARGET_PROXY = $00000001;
      WINHTTP_TIME_FORMAT_BUFSIZE = 62;
    
    type
      PURL_COMPONENTS = ^URL_COMPONENTS;
      URL_COMPONENTS = record
          dwStructSize : DWORD;
          lpszScheme : LPWSTR;
          dwSchemeLength : DWORD;
          nScheme : INTERNET_SCHEME;
          lpszHostName : LPWSTR;
          dwHostNameLength : DWORD;
          nPort : INTERNET_PORT;
          lpszUserName : LPWSTR;
          dwUserNameLength : DWORD;
          lpszPassword : LPWSTR;
          dwPasswordLength : DWORD;
          lpszUrlPath : LPWSTR;
          dwUrlPathLength : DWORD;
          lpszExtraInfo : LPWSTR;
          dwExtraInfoLength : DWORD;
        end;
      LPURL_COMPONENTS = PURL_COMPONENTS;
      PLPURL_COMPONENTS = ^LPURL_COMPONENTS;
    
      PURL_COMPONENTSW = ^URL_COMPONENTSW;
      URL_COMPONENTSW = URL_COMPONENTS;
    
      PLPURL_COMPONENTSW = ^LPURL_COMPONENTSW;
      LPURL_COMPONENTSW = LPURL_COMPONENTS;
    
      PWINHTTP_ASYNC_RESULT = ^WINHTTP_ASYNC_RESULT;
      WINHTTP_ASYNC_RESULT = record
          dwResult : DWORD_PTR;
          dwError : DWORD;
        end;
      LPWINHTTP_ASYNC_RESULT = PWINHTTP_ASYNC_RESULT;
      PLPWINHTTP_ASYNC_RESULT = ^LPWINHTTP_ASYNC_RESULT;
    
      PWINHTTP_CERTIFICATE_INFO = ^WINHTTP_CERTIFICATE_INFO;
      WINHTTP_CERTIFICATE_INFO = record
          ftExpiry : FILETIME;
          ftStart : FILETIME;
          lpszSubjectInfo : LPWSTR;
          lpszIssuerInfo : LPWSTR;
          lpszProtocolName : LPWSTR;
          lpszSignatureAlgName : LPWSTR;
          lpszEncryptionAlgName : LPWSTR;
          dwKeySize : DWORD;
        end;
    
      PWINHTTP_PROXY_INFO = ^WINHTTP_PROXY_INFO;
      WINHTTP_PROXY_INFO = record
          dwAccessType : DWORD;
          lpszProxy : LPCWSTR;
          lpszProxyBypass : LPCWSTR;
        end;
      LPWINHTTP_PROXY_INFO = PWINHTTP_PROXY_INFO;
      PLPWINHTTP_PROXY_INFO = ^LPWINHTTP_PROXY_INFO;
    
      PWINHTTP_PROXY_INFOW = ^WINHTTP_PROXY_INFOW;
      WINHTTP_PROXY_INFOW = WINHTTP_PROXY_INFO;
    
      PLPWINHTTP_PROXY_INFOW = ^LPWINHTTP_PROXY_INFOW;
      LPWINHTTP_PROXY_INFOW = LPWINHTTP_PROXY_INFO;
    
      PWINHTTP_CURRENT_USER_IE_PROXY_CONFIG = ^WINHTTP_CURRENT_USER_IE_PROXY_CONFIG;
      WINHTTP_CURRENT_USER_IE_PROXY_CONFIG = record
          fAutoDetect : WINBOOL;
          lpszAutoConfigUrl : LPWSTR;
          lpszProxy : LPWSTR;
          lpszProxyBypass : LPWSTR;
        end;
    
      WINHTTP_STATUS_CALLBACK = procedure (_para1:HINTERNET; _para2:DWORD_PTR; _para3:DWORD; _para4:LPVOID; _para5:DWORD);
    
      PWINHTTP_AUTOPROXY_OPTIONS = ^WINHTTP_AUTOPROXY_OPTIONS;
      WINHTTP_AUTOPROXY_OPTIONS = record
          dwFlags : DWORD;
          dwAutoDetectFlags : DWORD;
          lpszAutoConfigUrl : LPCWSTR;
          lpvReserved : LPVOID;
          dwReserved : DWORD;
          fAutoLogonIfChallenged : WINBOOL;
        end;
    
      PHTTP_VERSION_INFO = ^HTTP_VERSION_INFO;
      HTTP_VERSION_INFO = record
          dwMajorVersion : DWORD;
          dwMinorVersion : DWORD;
        end;
      LPHTTP_VERSION_INFO = PHTTP_VERSION_INFO;
      PLPHTTP_VERSION_INFO = ^LPHTTP_VERSION_INFO;
    
    function WINHTTP_INVALID_STATUS_CALLBACK : WINHTTP_STATUS_CALLBACK;
    function WinHttpAddRequestHeaders(_para1:HINTERNET; _para2:LPCWSTR; _para3:DWORD; _para4:DWORD):WINBOOL;external External_library name 'WinHttpAddRequestHeaders';
    function WinHttpDetectAutoProxyConfigUrl(_para1:DWORD; _para2:PLPWSTR):WINBOOL;external External_library name 'WinHttpDetectAutoProxyConfigUrl';
    function WinHttpCheckPlatform:WINBOOL;external External_library name 'WinHttpCheckPlatform';
    function WinHttpCloseHandle(_para1:HINTERNET):WINBOOL;external External_library name 'WinHttpCloseHandle';
    function WinHttpConnect(_para1:HINTERNET; _para2:LPCWSTR; _para3:INTERNET_PORT; _para4:DWORD):HINTERNET;external External_library name 'WinHttpConnect';
    function WinHttpCrackUrl(_para1:LPCWSTR; _para2:DWORD; _para3:DWORD; _para4:LPURL_COMPONENTS):WINBOOL;external External_library name 'WinHttpCrackUrl';
    function WinHttpCreateUrl(_para1:LPURL_COMPONENTS; _para2:DWORD; _para3:LPWSTR; _para4:LPDWORD):WINBOOL;external External_library name 'WinHttpCreateUrl';
    function WinHttpGetDefaultProxyConfiguration(_para1:PWINHTTP_PROXY_INFO):WINBOOL;external External_library name 'WinHttpGetDefaultProxyConfiguration';
    function WinHttpGetIEProxyConfigForCurrentUser(_para1:PWINHTTP_CURRENT_USER_IE_PROXY_CONFIG):WINBOOL;external External_library name 'WinHttpGetIEProxyConfigForCurrentUser';
    function WinHttpGetProxyForUrl(_para1:HINTERNET; _para2:LPCWSTR; _para3:PWINHTTP_AUTOPROXY_OPTIONS; _para4:PWINHTTP_PROXY_INFO):WINBOOL;external External_library name 'WinHttpGetProxyForUrl';
    function WinHttpOpen(_para1:LPCWSTR; _para2:DWORD; _para3:LPCWSTR; _para4:LPCWSTR; _para5:DWORD):HINTERNET;external External_library name 'WinHttpOpen';
    function WinHttpOpenRequest(_para1:HINTERNET; _para2:LPCWSTR; _para3:LPCWSTR; _para4:LPCWSTR; _para5:LPCWSTR;
      _para6:LPCWSTR; _para7:DWORD):HINTERNET;external External_library name 'WinHttpOpenRequest';
    function WinHttpQueryAuthParams(_para1:HINTERNET; _para2:DWORD; _para3:LPVOID):WINBOOL;external External_library name 'WinHttpQueryAuthParams';
    function WinHttpQueryAuthSchemes(_para1:HINTERNET; _para2:LPDWORD; _para3:LPDWORD; _para4:LPDWORD):WINBOOL;external External_library name 'WinHttpQueryAuthSchemes';
    function WinHttpQueryDataAvailable(_para1:HINTERNET; _para2:LPDWORD):WINBOOL;external External_library name 'WinHttpQueryDataAvailable';
    function WinHttpQueryHeaders(_para1:HINTERNET; _para2:DWORD; _para3:LPCWSTR; _para4:LPVOID; _para5:LPDWORD;
      _para6:LPDWORD):WINBOOL;external External_library name 'WinHttpQueryHeaders';
    function WinHttpQueryOption(_para1:HINTERNET; _para2:DWORD; _para3:LPVOID; _para4:LPDWORD):WINBOOL;external External_library name 'WinHttpQueryOption';
    function WinHttpReadData(_para1:HINTERNET; _para2:LPVOID; _para3:DWORD; _para4:LPDWORD):WINBOOL;external External_library name 'WinHttpReadData';
    function WinHttpReceiveResponse(_para1:HINTERNET; _para2:LPVOID):WINBOOL;external External_library name 'WinHttpReceiveResponse';
    function WinHttpSendRequest(_para1:HINTERNET; _para2:LPCWSTR; _para3:DWORD; _para4:LPVOID; _para5:DWORD;
      _para6:DWORD; _para7:DWORD_PTR):WINBOOL;external External_library name 'WinHttpSendRequest';
    function WinHttpSetDefaultProxyConfiguration(_para1:PWINHTTP_PROXY_INFO):WINBOOL;external External_library name 'WinHttpSetDefaultProxyConfiguration';
    function WinHttpSetCredentials(_para1:HINTERNET; _para2:DWORD; _para3:DWORD; _para4:LPCWSTR; _para5:LPCWSTR;
       _para6:LPVOID):WINBOOL;external External_library name 'WinHttpSetCredentials';
    function WinHttpSetOption(_para1:HINTERNET; _para2:DWORD; _para3:LPVOID; _para4:DWORD):WINBOOL;external External_library name 'WinHttpSetOption';
    function WinHttpSetStatusCallback(_para1:HINTERNET; _para2:WINHTTP_STATUS_CALLBACK; _para3:DWORD; _para4:DWORD_PTR):WINHTTP_STATUS_CALLBACK;external External_library name 'WinHttpSetStatusCallback';
    function WinHttpSetTimeouts(_para1:HINTERNET; _para2:longint; _para3:longint; _para4:longint; _para5:longint):WINBOOL;external External_library name 'WinHttpSetTimeouts';
    function WinHttpTimeFromSystemTime(_para1:PSYSTEMTIME; _para2:LPWSTR):WINBOOL;external External_library name 'WinHttpTimeFromSystemTime';
    function WinHttpTimeToSystemTime(_para1:LPCWSTR; _para2:PSYSTEMTIME):WINBOOL;external External_library name 'WinHttpTimeToSystemTime';
    function WinHttpWriteData(_para1:HINTERNET; _para2:LPCVOID; _para3:DWORD; _para4:LPDWORD):WINBOOL;external External_library name 'WinHttpWriteData';
    
    implementation
    
    function WINHTTP_INVALID_STATUS_CALLBACK : WINHTTP_STATUS_CALLBACK;
    begin
      WINHTTP_INVALID_STATUS_CALLBACK:=WINHTTP_STATUS_CALLBACK(-(1));
    end;
    
    end.
    
    winhttp.2.pas (26,676 bytes)
  • winhttp.3.pas (28,257 bytes)
    {
        This file is part of the Free Pascal run time library.
        Copyright (c) 2017 by Free Pascal development team.
    
        See the file COPYING.FPC, included in this distribution,
        for details about the copyright.
    
        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
        Original copyright statement follows.
    
     * Copyright (C) 2007 Francois Gouget
     *
     * This library is free software; you can redistribute it and/or
     * modify it under the terms of the GNU Lesser General Public
     * License as published by the Free Software Foundation; either
     * version 2.1 of the License, or (at your option) any later version.
     *
     * This library is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     * Lesser General Public License for more details.
     *
     * You should have received a copy of the GNU Lesser General Public
     * License along with this library; if not, write to the Free Software
     * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
    }
    
    unit winhttp;
    
    interface
    
    uses
      Windows;
    
     {$ifdef win64}
       {$packrecords 8}
     {$else}
       {$packrecords 4}
     {$endif}
    
    const
      LIB_WINHTTPDLL = 'winhttp.dll';
    
    type
      PHINTERNET = ^HINTERNET;
      HINTERNET = LPVOID;
    
      PLPHINTERNET = ^LPHINTERNET;
      LPHINTERNET = PHINTERNET;
    
    const
      INTERNET_DEFAULT_PORT = 0;
      INTERNET_DEFAULT_HTTP_PORT = 80;
      INTERNET_DEFAULT_HTTPS_PORT = 443;
    
    type
      PINTERNET_PORT = ^INTERNET_PORT;
      INTERNET_PORT = word;
    
      PLPINTERNET_PORT = ^LPINTERNET_PORT;
      LPINTERNET_PORT = PINTERNET_PORT;
    
    const
      INTERNET_SCHEME_HTTP = 1;
      INTERNET_SCHEME_HTTPS = 2;
    
    type
      PINTERNET_SCHEME = ^INTERNET_SCHEME;
      INTERNET_SCHEME = longint;
      LPINTERNET_SCHEME = PINTERNET_SCHEME;
      PLPINTERNET_SCHEME = ^LPINTERNET_SCHEME;
    
    const
      ICU_ESCAPE = $80000000;
      { flags for WinHttpOpen  }
      WINHTTP_FLAG_ASYNC = $10000000;
      { flags for WinHttpOpenRequest  }
      WINHTTP_FLAG_ESCAPE_PERCENT = $00000004;
      WINHTTP_FLAG_NULL_CODEPAGE = $00000008;
      WINHTTP_FLAG_ESCAPE_DISABLE = $00000040;
      WINHTTP_FLAG_ESCAPE_DISABLE_QUERY = $00000080;
      WINHTTP_FLAG_BYPASS_PROXY_CACHE = $00000100;
      WINHTTP_FLAG_REFRESH = WINHTTP_FLAG_BYPASS_PROXY_CACHE;
      WINHTTP_FLAG_SECURE = $00800000;
      WINHTTP_ACCESS_TYPE_DEFAULT_PROXY = 0;
      WINHTTP_ACCESS_TYPE_NO_PROXY = 1;
      WINHTTP_ACCESS_TYPE_NAMED_PROXY = 3;
      WINHTTP_NO_PROXY_NAME = nil;
      WINHTTP_NO_PROXY_BYPASS = nil;
      WINHTTP_NO_REFERER = nil;
      WINHTTP_DEFAULT_ACCEPT_TYPES = nil;
      WINHTTP_NO_ADDITIONAL_HEADERS = nil;
      WINHTTP_NO_REQUEST_DATA = nil;
      WINHTTP_HEADER_NAME_BY_INDEX = nil;
      WINHTTP_NO_OUTPUT_BUFFER = nil;
      WINHTTP_NO_HEADER_INDEX = nil;
      WINHTTP_ADDREQ_INDEX_MASK = $0000FFFF;
      WINHTTP_ADDREQ_FLAGS_MASK = $FFFF0000;
      WINHTTP_ADDREQ_FLAG_ADD_IF_NEW = $10000000;
      WINHTTP_ADDREQ_FLAG_ADD = $20000000;
      WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA = $40000000;
      WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON = $01000000;
      WINHTTP_ADDREQ_FLAG_COALESCE = WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA;
      WINHTTP_ADDREQ_FLAG_REPLACE = $80000000;
      WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH = 0;
      { flags for WinHttpSet/QueryOptions  }
      WINHTTP_OPTION_CALLBACK = 1;
      WINHTTP_FIRST_OPTION = WINHTTP_OPTION_CALLBACK;
      WINHTTP_OPTION_RESOLVE_TIMEOUT = 2;
      WINHTTP_OPTION_CONNECT_TIMEOUT = 3;
      WINHTTP_OPTION_CONNECT_RETRIES = 4;
      WINHTTP_OPTION_SEND_TIMEOUT = 5;
      WINHTTP_OPTION_RECEIVE_TIMEOUT = 6;
      WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT = 7;
      WINHTTP_OPTION_HANDLE_TYPE = 9;
      WINHTTP_OPTION_READ_BUFFER_SIZE = 12;
      WINHTTP_OPTION_WRITE_BUFFER_SIZE = 13;
      WINHTTP_OPTION_PARENT_HANDLE = 21;
      WINHTTP_OPTION_EXTENDED_ERROR = 24;
      WINHTTP_OPTION_SECURITY_FLAGS = 31;
      WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT = 32;
      WINHTTP_OPTION_URL = 34;
      WINHTTP_OPTION_SECURITY_KEY_BITNESS = 36;
      WINHTTP_OPTION_PROXY = 38;
      WINHTTP_OPTION_USER_AGENT = 41;
      WINHTTP_OPTION_CONTEXT_VALUE = 45;
      WINHTTP_OPTION_CLIENT_CERT_CONTEXT = 47;
      WINHTTP_OPTION_REQUEST_PRIORITY = 58;
      WINHTTP_OPTION_HTTP_VERSION = 59;
      WINHTTP_OPTION_DISABLE_FEATURE = 63;
      WINHTTP_OPTION_CODEPAGE = 68;
      WINHTTP_OPTION_MAX_CONNS_PER_SERVER = 73;
      WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER = 74;
      WINHTTP_OPTION_AUTOLOGON_POLICY = 77;
      WINHTTP_OPTION_SERVER_CERT_CONTEXT = 78;
      WINHTTP_OPTION_ENABLE_FEATURE = 79;
      WINHTTP_OPTION_WORKER_THREAD_COUNT = 80;
      WINHTTP_OPTION_PASSPORT_COBRANDING_TEXT = 81;
      WINHTTP_OPTION_PASSPORT_COBRANDING_URL = 82;
      WINHTTP_OPTION_CONFIGURE_PASSPORT_AUTH = 83;
      WINHTTP_OPTION_SECURE_PROTOCOLS = 84;
      WINHTTP_OPTION_ENABLETRACING = 85;
      WINHTTP_OPTION_PASSPORT_SIGN_OUT = 86;
      WINHTTP_OPTION_PASSPORT_RETURN_URL = 87;
      WINHTTP_OPTION_REDIRECT_POLICY = 88;
      WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS = 89;
      WINHTTP_OPTION_MAX_HTTP_STATUS_CONTINUE = 90;
      WINHTTP_OPTION_MAX_RESPONSE_HEADER_SIZE = 91;
      WINHTTP_OPTION_MAX_RESPONSE_DRAIN_SIZE = 92;
      WINHTTP_OPTION_CONNECTION_INFO = 93;
      WINHTTP_OPTION_CLIENT_CERT_ISSUER_LIST = 94;
      WINHTTP_OPTION_SPN = 96;
      WINHTTP_OPTION_GLOBAL_PROXY_CREDS = 97;
      WINHTTP_OPTION_GLOBAL_SERVER_CREDS = 98;
      WINHTTP_OPTION_UNLOAD_NOTIFY_EVENT = 99;
      WINHTTP_OPTION_REJECT_USERPWD_IN_URL = 100;
      WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS = 101;
      WINHTTP_LAST_OPTION = WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS;
      WINHTTP_OPTION_USERNAME = $1000;
      WINHTTP_OPTION_PASSWORD = $1001;
      WINHTTP_OPTION_PROXY_USERNAME = $1002;
      WINHTTP_OPTION_PROXY_PASSWORD = $1003;
      WINHTTP_CONNS_PER_SERVER_UNLIMITED = $FFFFFFFF;
      WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM = 0;
      WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW = 1;
      WINHTTP_AUTOLOGON_SECURITY_LEVEL_HIGH = 2;
      WINHTTP_AUTOLOGON_SECURITY_LEVEL_DEFAULT = WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM;
      WINHTTP_OPTION_REDIRECT_POLICY_NEVER = 0;
      WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP = 1;
      WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS = 2;
      WINHTTP_OPTION_REDIRECT_POLICY_LAST = WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS;
      WINHTTP_OPTION_REDIRECT_POLICY_DEFAULT =
        WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP;
      WINHTTP_DISABLE_PASSPORT_AUTH = $00000000;
      WINHTTP_ENABLE_PASSPORT_AUTH = $10000000;
      WINHTTP_DISABLE_PASSPORT_KEYRING = $20000000;
      WINHTTP_ENABLE_PASSPORT_KEYRING = $40000000;
      WINHTTP_DISABLE_COOKIES = $00000001;
      WINHTTP_DISABLE_REDIRECTS = $00000002;
      WINHTTP_DISABLE_AUTHENTICATION = $00000004;
      WINHTTP_DISABLE_KEEP_ALIVE = $00000008;
      WINHTTP_ENABLE_SSL_REVOCATION = $00000001;
      WINHTTP_ENABLE_SSL_REVERT_IMPERSONATION = $00000002;
      WINHTTP_DISABLE_SPN_SERVER_PORT = $00000000;
      WINHTTP_ENABLE_SPN_SERVER_PORT = $00000001;
      WINHTTP_OPTION_SPN_MASK = WINHTTP_ENABLE_SPN_SERVER_PORT;
    
      { WinHTTP error codes  }
      WINHTTP_ERROR_BASE = 12000;
      ERROR_WINHTTP_OUT_OF_HANDLES = WINHTTP_ERROR_BASE + 1;
      ERROR_WINHTTP_TIMEOUT = WINHTTP_ERROR_BASE + 2;
      ERROR_WINHTTP_INTERNAL_ERROR = WINHTTP_ERROR_BASE + 4;
      ERROR_WINHTTP_INVALID_URL = WINHTTP_ERROR_BASE + 5;
      ERROR_WINHTTP_UNRECOGNIZED_SCHEME = WINHTTP_ERROR_BASE + 6;
      ERROR_WINHTTP_NAME_NOT_RESOLVED = WINHTTP_ERROR_BASE + 7;
      ERROR_WINHTTP_INVALID_OPTION = WINHTTP_ERROR_BASE + 9;
      ERROR_WINHTTP_OPTION_NOT_SETTABLE = WINHTTP_ERROR_BASE + 11;
      ERROR_WINHTTP_SHUTDOWN = WINHTTP_ERROR_BASE + 12;
      ERROR_WINHTTP_LOGIN_FAILURE = WINHTTP_ERROR_BASE + 15;
      ERROR_WINHTTP_OPERATION_CANCELLED = WINHTTP_ERROR_BASE + 17;
      ERROR_WINHTTP_INCORRECT_HANDLE_TYPE = WINHTTP_ERROR_BASE + 18;
      ERROR_WINHTTP_INCORRECT_HANDLE_STATE = WINHTTP_ERROR_BASE + 19;
      ERROR_WINHTTP_CANNOT_CONNECT = WINHTTP_ERROR_BASE + 29;
      ERROR_WINHTTP_CONNECTION_ERROR = WINHTTP_ERROR_BASE + 30;
      ERROR_WINHTTP_RESEND_REQUEST = WINHTTP_ERROR_BASE + 32;
      ERROR_WINHTTP_SECURE_CERT_DATE_INVALID = WINHTTP_ERROR_BASE + 37;
      ERROR_WINHTTP_SECURE_CERT_CN_INVALID = WINHTTP_ERROR_BASE + 38;
      ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED = WINHTTP_ERROR_BASE + 44;
      ERROR_WINHTTP_SECURE_INVALID_CA = WINHTTP_ERROR_BASE + 45;
      ERROR_WINHTTP_SECURE_CERT_REV_FAILED = WINHTTP_ERROR_BASE + 57;
      ERROR_WINHTTP_CANNOT_CALL_BEFORE_OPEN = WINHTTP_ERROR_BASE + 100;
      ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND = WINHTTP_ERROR_BASE + 101;
      ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND = WINHTTP_ERROR_BASE + 102;
      ERROR_WINHTTP_CANNOT_CALL_AFTER_OPEN = WINHTTP_ERROR_BASE + 103;
      ERROR_WINHTTP_HEADER_NOT_FOUND = WINHTTP_ERROR_BASE + 150;
      ERROR_WINHTTP_INVALID_SERVER_RESPONSE = WINHTTP_ERROR_BASE + 152;
      ERROR_WINHTTP_INVALID_HEADER = WINHTTP_ERROR_BASE + 153;
      ERROR_WINHTTP_INVALID_QUERY_REQUEST = WINHTTP_ERROR_BASE + 154;
      ERROR_WINHTTP_HEADER_ALREADY_EXISTS = WINHTTP_ERROR_BASE + 155;
      ERROR_WINHTTP_REDIRECT_FAILED = WINHTTP_ERROR_BASE + 156;
      ERROR_WINHTTP_SECURE_CHANNEL_ERROR = WINHTTP_ERROR_BASE + 157;
      ERROR_WINHTTP_BAD_AUTO_PROXY_SCRIPT = WINHTTP_ERROR_BASE + 166;
      ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT = WINHTTP_ERROR_BASE + 167;
      ERROR_WINHTTP_SECURE_INVALID_CERT = WINHTTP_ERROR_BASE + 169;
      ERROR_WINHTTP_SECURE_CERT_REVOKED = WINHTTP_ERROR_BASE + 170;
      ERROR_WINHTTP_NOT_INITIALIZED = WINHTTP_ERROR_BASE + 172;
      ERROR_WINHTTP_SECURE_FAILURE = WINHTTP_ERROR_BASE + 175;
      ERROR_WINHTTP_AUTO_PROXY_SERVICE_ERROR = WINHTTP_ERROR_BASE + 178;
      ERROR_WINHTTP_SECURE_CERT_WRONG_USAGE = WINHTTP_ERROR_BASE + 179;
      ERROR_WINHTTP_AUTODETECTION_FAILED = WINHTTP_ERROR_BASE + 180;
      ERROR_WINHTTP_HEADER_COUNT_EXCEEDED = WINHTTP_ERROR_BASE + 181;
      ERROR_WINHTTP_HEADER_SIZE_OVERFLOW = WINHTTP_ERROR_BASE + 182;
      ERROR_WINHTTP_CHUNKED_ENCODING_HEADER_SIZE_OVERFLOW = WINHTTP_ERROR_BASE + 183;
      ERROR_WINHTTP_RESPONSE_DRAIN_OVERFLOW = WINHTTP_ERROR_BASE + 184;
      ERROR_WINHTTP_CLIENT_CERT_NO_PRIVATE_KEY = WINHTTP_ERROR_BASE + 185;
      ERROR_WINHTTP_CLIENT_CERT_NO_ACCESS_PRIVATE_KEY = WINHTTP_ERROR_BASE + 186;
      WINHTTP_ERROR_LAST = WINHTTP_ERROR_BASE + 186;
      { WinHttp status codes  }
      HTTP_STATUS_CONTINUE = 100;
      HTTP_STATUS_SWITCH_PROTOCOLS = 101;
      HTTP_STATUS_OK = 200;
      HTTP_STATUS_CREATED = 201;
      HTTP_STATUS_ACCEPTED = 202;
      HTTP_STATUS_PARTIAL = 203;
      HTTP_STATUS_NO_CONTENT = 204;
      HTTP_STATUS_RESET_CONTENT = 205;
      HTTP_STATUS_PARTIAL_CONTENT = 206;
      HTTP_STATUS_WEBDAV_MULTI_STATUS = 207;
      HTTP_STATUS_AMBIGUOUS = 300;
      HTTP_STATUS_MOVED = 301;
      HTTP_STATUS_REDIRECT = 302;
      HTTP_STATUS_REDIRECT_METHOD = 303;
      HTTP_STATUS_NOT_MODIFIED = 304;
      HTTP_STATUS_USE_PROXY = 305;
      HTTP_STATUS_REDIRECT_KEEP_VERB = 307;
      HTTP_STATUS_BAD_REQUEST = 400;
      HTTP_STATUS_DENIED = 401;
      HTTP_STATUS_PAYMENT_REQ = 402;
      HTTP_STATUS_FORBIDDEN = 403;
      HTTP_STATUS_NOT_FOUND = 404;
      HTTP_STATUS_BAD_METHOD = 405;
      HTTP_STATUS_NONE_ACCEPTABLE = 406;
      HTTP_STATUS_PROXY_AUTH_REQ = 407;
      HTTP_STATUS_REQUEST_TIMEOUT = 408;
      HTTP_STATUS_CONFLICT = 409;
      HTTP_STATUS_GONE = 410;
      HTTP_STATUS_LENGTH_REQUIRED = 411;
      HTTP_STATUS_PRECOND_FAILED = 412;
      HTTP_STATUS_REQUEST_TOO_LARGE = 413;
      HTTP_STATUS_URI_TOO_LONG = 414;
      HTTP_STATUS_UNSUPPORTED_MEDIA = 415;
      HTTP_STATUS_RETRY_WITH = 449;
      HTTP_STATUS_SERVER_ERROR = 500;
      HTTP_STATUS_NOT_SUPPORTED = 501;
      HTTP_STATUS_BAD_GATEWAY = 502;
      HTTP_STATUS_SERVICE_UNAVAIL = 503;
      HTTP_STATUS_GATEWAY_TIMEOUT = 504;
      HTTP_STATUS_VERSION_NOT_SUP = 505;
      HTTP_STATUS_FIRST = HTTP_STATUS_CONTINUE;
      HTTP_STATUS_LAST = HTTP_STATUS_VERSION_NOT_SUP;
      SECURITY_FLAG_IGNORE_UNKNOWN_CA = $00000100;
      SECURITY_FLAG_IGNORE_CERT_DATE_INVALID = $00002000;
      SECURITY_FLAG_IGNORE_CERT_CN_INVALID = $00001000;
      SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE = $00000200;
      SECURITY_FLAG_SECURE = $00000001;
      SECURITY_FLAG_STRENGTH_WEAK = $10000000;
      SECURITY_FLAG_STRENGTH_MEDIUM = $40000000;
      SECURITY_FLAG_STRENGTH_STRONG = $20000000;
      ICU_NO_ENCODE = $20000000;
      ICU_DECODE = $10000000;
      ICU_NO_META = $08000000;
      ICU_ENCODE_SPACES_ONLY = $04000000;
      ICU_BROWSER_MODE = $02000000;
      ICU_ENCODE_PERCENT = $00001000;
      { Query flags  }
      WINHTTP_QUERY_MIME_VERSION = 0;
      WINHTTP_QUERY_CONTENT_TYPE = 1;
      WINHTTP_QUERY_CONTENT_TRANSFER_ENCODING = 2;
      WINHTTP_QUERY_CONTENT_ID = 3;
      WINHTTP_QUERY_CONTENT_DESCRIPTION = 4;
      WINHTTP_QUERY_CONTENT_LENGTH = 5;
      WINHTTP_QUERY_CONTENT_LANGUAGE = 6;
      WINHTTP_QUERY_ALLOW = 7;
      WINHTTP_QUERY_PUBLIC = 8;
      WINHTTP_QUERY_DATE = 9;
      WINHTTP_QUERY_EXPIRES = 10;
      WINHTTP_QUERY_LAST_MODIFIED = 11;
      WINHTTP_QUERY_MESSAGE_ID = 12;
      WINHTTP_QUERY_URI = 13;
      WINHTTP_QUERY_DERIVED_FROM = 14;
      WINHTTP_QUERY_COST = 15;
      WINHTTP_QUERY_LINK = 16;
      WINHTTP_QUERY_PRAGMA = 17;
      WINHTTP_QUERY_VERSION = 18;
      WINHTTP_QUERY_STATUS_CODE = 19;
      WINHTTP_QUERY_STATUS_TEXT = 20;
      WINHTTP_QUERY_RAW_HEADERS = 21;
      WINHTTP_QUERY_RAW_HEADERS_CRLF = 22;
      WINHTTP_QUERY_CONNECTION = 23;
      WINHTTP_QUERY_ACCEPT = 24;
      WINHTTP_QUERY_ACCEPT_CHARSET = 25;
      WINHTTP_QUERY_ACCEPT_ENCODING = 26;
      WINHTTP_QUERY_ACCEPT_LANGUAGE = 27;
      WINHTTP_QUERY_AUTHORIZATION = 28;
      WINHTTP_QUERY_CONTENT_ENCODING = 29;
      WINHTTP_QUERY_FORWARDED = 30;
      WINHTTP_QUERY_FROM = 31;
      WINHTTP_QUERY_IF_MODIFIED_SINCE = 32;
      WINHTTP_QUERY_LOCATION = 33;
      WINHTTP_QUERY_ORIG_URI = 34;
      WINHTTP_QUERY_REFERER = 35;
      WINHTTP_QUERY_RETRY_AFTER = 36;
      WINHTTP_QUERY_SERVER = 37;
      WINHTTP_QUERY_TITLE = 38;
      WINHTTP_QUERY_USER_AGENT = 39;
      WINHTTP_QUERY_WWW_AUTHENTICATE = 40;
      WINHTTP_QUERY_PROXY_AUTHENTICATE = 41;
      WINHTTP_QUERY_ACCEPT_RANGES = 42;
      WINHTTP_QUERY_SET_COOKIE = 43;
      WINHTTP_QUERY_COOKIE = 44;
      WINHTTP_QUERY_REQUEST_METHOD = 45;
      WINHTTP_QUERY_REFRESH = 46;
      WINHTTP_QUERY_CONTENT_DISPOSITION = 47;
      WINHTTP_QUERY_AGE = 48;
      WINHTTP_QUERY_CACHE_CONTROL = 49;
      WINHTTP_QUERY_CONTENT_BASE = 50;
      WINHTTP_QUERY_CONTENT_LOCATION = 51;
      WINHTTP_QUERY_CONTENT_MD5 = 52;
      WINHTTP_QUERY_CONTENT_RANGE = 53;
      WINHTTP_QUERY_ETAG = 54;
      WINHTTP_QUERY_HOST = 55;
      WINHTTP_QUERY_IF_MATCH = 56;
      WINHTTP_QUERY_IF_NONE_MATCH = 57;
      WINHTTP_QUERY_IF_RANGE = 58;
      WINHTTP_QUERY_IF_UNMODIFIED_SINCE = 59;
      WINHTTP_QUERY_MAX_FORWARDS = 60;
      WINHTTP_QUERY_PROXY_AUTHORIZATION = 61;
      WINHTTP_QUERY_RANGE = 62;
      WINHTTP_QUERY_TRANSFER_ENCODING = 63;
      WINHTTP_QUERY_UPGRADE = 64;
      WINHTTP_QUERY_VARY = 65;
      WINHTTP_QUERY_VIA = 66;
      WINHTTP_QUERY_WARNING = 67;
      WINHTTP_QUERY_EXPECT = 68;
      WINHTTP_QUERY_PROXY_CONNECTION = 69;
      WINHTTP_QUERY_UNLESS_MODIFIED_SINCE = 70;
      WINHTTP_QUERY_PROXY_SUPPORT = 75;
      WINHTTP_QUERY_AUTHENTICATION_INFO = 76;
      WINHTTP_QUERY_PASSPORT_URLS = 77;
      WINHTTP_QUERY_PASSPORT_CONFIG = 78;
      WINHTTP_QUERY_MAX = 78;
      WINHTTP_QUERY_CUSTOM = 65535;
      WINHTTP_QUERY_FLAG_REQUEST_HEADERS = $80000000;
      WINHTTP_QUERY_FLAG_SYSTEMTIME = $40000000;
      WINHTTP_QUERY_FLAG_NUMBER = $20000000;
      { Callback options  }
      WINHTTP_CALLBACK_STATUS_RESOLVING_NAME = $00000001;
      WINHTTP_CALLBACK_STATUS_NAME_RESOLVED = $00000002;
      WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER = $00000004;
      WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER = $00000008;
      WINHTTP_CALLBACK_STATUS_SENDING_REQUEST = $00000010;
      WINHTTP_CALLBACK_STATUS_REQUEST_SENT = $00000020;
      WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE = $00000040;
      WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED = $00000080;
      WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION = $00000100;
      WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED = $00000200;
      WINHTTP_CALLBACK_STATUS_HANDLE_CREATED = $00000400;
      WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING = $00000800;
      WINHTTP_CALLBACK_STATUS_DETECTING_PROXY = $00001000;
      WINHTTP_CALLBACK_STATUS_REDIRECT = $00004000;
      WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE = $00008000;
      WINHTTP_CALLBACK_STATUS_SECURE_FAILURE = $00010000;
      WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE = $00020000;
      WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE = $00040000;
      WINHTTP_CALLBACK_STATUS_READ_COMPLETE = $00080000;
      WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE = $00100000;
      WINHTTP_CALLBACK_STATUS_REQUEST_ERROR = $00200000;
      WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE = $00400000;
      WINHTTP_CALLBACK_FLAG_RESOLVE_NAME =
        WINHTTP_CALLBACK_STATUS_RESOLVING_NAME or WINHTTP_CALLBACK_STATUS_NAME_RESOLVED;
      WINHTTP_CALLBACK_FLAG_CONNECT_TO_SERVER =
        WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER or
        WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER;
      WINHTTP_CALLBACK_FLAG_SEND_REQUEST =
        WINHTTP_CALLBACK_STATUS_SENDING_REQUEST or WINHTTP_CALLBACK_STATUS_REQUEST_SENT;
      WINHTTP_CALLBACK_FLAG_RECEIVE_RESPONSE =
        WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE or WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED;
      WINHTTP_CALLBACK_FLAG_CLOSE_CONNECTION =
        WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION or WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED;
      WINHTTP_CALLBACK_FLAG_HANDLES =
        WINHTTP_CALLBACK_STATUS_HANDLE_CREATED or WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING;
      WINHTTP_CALLBACK_FLAG_DETECTING_PROXY = WINHTTP_CALLBACK_STATUS_DETECTING_PROXY;
      WINHTTP_CALLBACK_FLAG_REDIRECT = WINHTTP_CALLBACK_STATUS_REDIRECT;
      WINHTTP_CALLBACK_FLAG_INTERMEDIATE_RESPONSE =
        WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE;
      WINHTTP_CALLBACK_FLAG_SECURE_FAILURE = WINHTTP_CALLBACK_STATUS_SECURE_FAILURE;
      WINHTTP_CALLBACK_FLAG_SENDREQUEST_COMPLETE =
        WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE;
      WINHTTP_CALLBACK_FLAG_HEADERS_AVAILABLE = WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE;
      WINHTTP_CALLBACK_FLAG_DATA_AVAILABLE = WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE;
      WINHTTP_CALLBACK_FLAG_READ_COMPLETE = WINHTTP_CALLBACK_STATUS_READ_COMPLETE;
      WINHTTP_CALLBACK_FLAG_WRITE_COMPLETE = WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE;
      WINHTTP_CALLBACK_FLAG_REQUEST_ERROR = WINHTTP_CALLBACK_STATUS_REQUEST_ERROR;
      WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS =
        ((((WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE or
        WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE) or WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE) or
        WINHTTP_CALLBACK_STATUS_READ_COMPLETE) or WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE) or
        WINHTTP_CALLBACK_STATUS_REQUEST_ERROR;
      WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS = $ffffffff;
    
    const
      API_RECEIVE_RESPONSE = 1;
      API_QUERY_DATA_AVAILABLE = 2;
      API_READ_DATA = 3;
      API_WRITE_DATA = 4;
      API_SEND_REQUEST = 5;
      WINHTTP_HANDLE_TYPE_SESSION = 1;
      WINHTTP_HANDLE_TYPE_CONNECT = 2;
      WINHTTP_HANDLE_TYPE_REQUEST = 3;
      WINHTTP_CALLBACK_STATUS_FLAG_CERT_REV_FAILED = $00000001;
      WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CERT = $00000002;
      WINHTTP_CALLBACK_STATUS_FLAG_CERT_REVOKED = $00000004;
      WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CA = $00000008;
      WINHTTP_CALLBACK_STATUS_FLAG_CERT_CN_INVALID = $00000010;
      WINHTTP_CALLBACK_STATUS_FLAG_CERT_DATE_INVALID = $00000020;
      WINHTTP_CALLBACK_STATUS_FLAG_CERT_WRONG_USAGE = $00000040;
      WINHTTP_CALLBACK_STATUS_FLAG_SECURITY_CHANNEL_ERROR = $80000000;
      WINHTTP_FLAG_SECURE_PROTOCOL_SSL2 = $00000008;
      WINHTTP_FLAG_SECURE_PROTOCOL_SSL3 = $00000020;
      WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 = $00000080;
      WINHTTP_FLAG_SECURE_PROTOCOL_ALL =
        (WINHTTP_FLAG_SECURE_PROTOCOL_SSL2 or WINHTTP_FLAG_SECURE_PROTOCOL_SSL3) or
        WINHTTP_FLAG_SECURE_PROTOCOL_TLS1;
      WINHTTP_AUTH_SCHEME_BASIC = $00000001;
      WINHTTP_AUTH_SCHEME_NTLM = $00000002;
      WINHTTP_AUTH_SCHEME_PASSPORT = $00000004;
      WINHTTP_AUTH_SCHEME_DIGEST = $00000008;
      WINHTTP_AUTH_SCHEME_NEGOTIATE = $00000010;
      WINHTTP_AUTH_TARGET_SERVER = $00000000;
      WINHTTP_AUTH_TARGET_PROXY = $00000001;
      WINHTTP_TIME_FORMAT_BUFSIZE = 62;
    
    type
      PURL_COMPONENTS = ^URL_COMPONENTS;
    
      URL_COMPONENTS = record
        dwStructSize: DWORD;
        lpszScheme: LPWSTR;
        dwSchemeLength: DWORD;
        nScheme: INTERNET_SCHEME;
        lpszHostName: LPWSTR;
        dwHostNameLength: DWORD;
        nPort: INTERNET_PORT;
        lpszUserName: LPWSTR;
        dwUserNameLength: DWORD;
        lpszPassword: LPWSTR;
        dwPasswordLength: DWORD;
        lpszUrlPath: LPWSTR;
        dwUrlPathLength: DWORD;
        lpszExtraInfo: LPWSTR;
        dwExtraInfoLength: DWORD;
      end;
      LPURL_COMPONENTS = PURL_COMPONENTS;
      PLPURL_COMPONENTS = ^LPURL_COMPONENTS;
    
      PURL_COMPONENTSW = ^URL_COMPONENTSW;
      URL_COMPONENTSW = URL_COMPONENTS;
    
      PLPURL_COMPONENTSW = ^LPURL_COMPONENTSW;
      LPURL_COMPONENTSW = LPURL_COMPONENTS;
    
      PWINHTTP_ASYNC_RESULT = ^WINHTTP_ASYNC_RESULT;
    
      WINHTTP_ASYNC_RESULT = record
        dwResult: DWORD_PTR;
        dwError: DWORD;
      end;
      LPWINHTTP_ASYNC_RESULT = PWINHTTP_ASYNC_RESULT;
      PLPWINHTTP_ASYNC_RESULT = ^LPWINHTTP_ASYNC_RESULT;
    
      PWINHTTP_CERTIFICATE_INFO = ^WINHTTP_CERTIFICATE_INFO;
    
      WINHTTP_CERTIFICATE_INFO = record
        ftExpiry: FILETIME;
        ftStart: FILETIME;
        lpszSubjectInfo: LPWSTR;
        lpszIssuerInfo: LPWSTR;
        lpszProtocolName: LPWSTR;
        lpszSignatureAlgName: LPWSTR;
        lpszEncryptionAlgName: LPWSTR;
        dwKeySize: DWORD;
      end;
    
      PWINHTTP_PROXY_INFO = ^WINHTTP_PROXY_INFO;
    
      WINHTTP_PROXY_INFO = record
        dwAccessType: DWORD;
        lpszProxy: LPCWSTR;
        lpszProxyBypass: LPCWSTR;
      end;
      LPWINHTTP_PROXY_INFO = PWINHTTP_PROXY_INFO;
      PLPWINHTTP_PROXY_INFO = ^LPWINHTTP_PROXY_INFO;
    
      PWINHTTP_PROXY_INFOW = ^WINHTTP_PROXY_INFOW;
      WINHTTP_PROXY_INFOW = WINHTTP_PROXY_INFO;
    
      PLPWINHTTP_PROXY_INFOW = ^LPWINHTTP_PROXY_INFOW;
      LPWINHTTP_PROXY_INFOW = LPWINHTTP_PROXY_INFO;
    
      PWINHTTP_CURRENT_USER_IE_PROXY_CONFIG = ^WINHTTP_CURRENT_USER_IE_PROXY_CONFIG;
    
      WINHTTP_CURRENT_USER_IE_PROXY_CONFIG = record
        fAutoDetect: WINBOOL;
        lpszAutoConfigUrl: LPWSTR;
        lpszProxy: LPWSTR;
        lpszProxyBypass: LPWSTR;
      end;
    
      WINHTTP_STATUS_CALLBACK = procedure(hInterneth: HINTERNET;
        dwContext: DWORD_PTR; dwInternetStatus: DWORD; lpvStatusInformation: LPVOID;
        dwStatusInformationLength: DWORD); stdcall;
    
      PWINHTTP_AUTOPROXY_OPTIONS = ^WINHTTP_AUTOPROXY_OPTIONS;
    
      WINHTTP_AUTOPROXY_OPTIONS = record
        dwFlags: DWORD;
        dwAutoDetectFlags: DWORD;
        lpszAutoConfigUrl: LPCWSTR;
        lpvReserved: LPVOID;
        dwReserved: DWORD;
        fAutoLogonIfChallenged: WINBOOL;
      end;
    
      PHTTP_VERSION_INFO = ^HTTP_VERSION_INFO;
    
      HTTP_VERSION_INFO = record
        dwMajorVersion: DWORD;
        dwMinorVersion: DWORD;
      end;
      LPHTTP_VERSION_INFO = PHTTP_VERSION_INFO;
      PLPHTTP_VERSION_INFO = ^LPHTTP_VERSION_INFO;
    
    function WINHTTP_INVALID_STATUS_CALLBACK: WINHTTP_STATUS_CALLBACK;
    function WinHttpAddRequestHeaders(hRequest: HINTERNET; pwszHeaders: LPCWSTR;
      dwHeadersLength: DWORD; dwModifiers: DWORD): WINBOOL; stdcall;
      external LIB_WINHTTPDLL Name 'WinHttpAddRequestHeaders';
    function WinHttpDetectAutoProxyConfigUrl(dwAutoDetectFlags: DWORD;
      ppwszAutoConfigUrl: PLPWSTR): WINBOOL; stdcall;
      external LIB_WINHTTPDLL Name 'WinHttpDetectAutoProxyConfigUrl';
    function WinHttpCheckPlatform: WINBOOL; stdcall;
      external LIB_WINHTTPDLL Name 'WinHttpCheckPlatform';
    function WinHttpCloseHandle(hInterneth: HINTERNET): WINBOOL; stdcall;
      external LIB_WINHTTPDLL Name 'WinHttpCloseHandle';
    function WinHttpConnect(hSession: HINTERNET; pswzServerName: LPCWSTR;
      nServerPort: INTERNET_PORT; dwReserved: DWORD): HINTERNET; stdcall;
      external LIB_WINHTTPDLL Name 'WinHttpConnect';
    function WinHttpCrackUrl(pwszUrl: LPCWSTR; dwUrlLength: DWORD;
      dwFlags: DWORD; lpUrlComponents: LPURL_COMPONENTS): WINBOOL; stdcall;
      external LIB_WINHTTPDLL Name 'WinHttpCrackUrl';
    function WinHttpCreateUrl(lpUrlComponents: LPURL_COMPONENTS; dwFlags: DWORD;
      pwszUrl: LPWSTR; lpdwUrlLength: LPDWORD): WINBOOL; stdcall;
      external LIB_WINHTTPDLL Name 'WinHttpCreateUrl';
    function WinHttpGetDefaultProxyConfiguration(pProxyInfo: PWINHTTP_PROXY_INFO): WINBOOL;
      stdcall; external LIB_WINHTTPDLL Name 'WinHttpGetDefaultProxyConfiguration';
    function WinHttpGetIEProxyConfigForCurrentUser(pProxyConfig:
      PWINHTTP_CURRENT_USER_IE_PROXY_CONFIG): WINBOOL; stdcall;
      external LIB_WINHTTPDLL Name 'WinHttpGetIEProxyConfigForCurrentUser';
    function WinHttpGetProxyForUrl(hSession: HINTERNET; lpcwszUrl: LPCWSTR;
      pAutoProxyOptions: PWINHTTP_AUTOPROXY_OPTIONS; pProxyInfo: PWINHTTP_PROXY_INFO): WINBOOL;
      stdcall; external LIB_WINHTTPDLL Name 'WinHttpGetProxyForUrl';
    function WinHttpOpen(pwszUserAgent: LPCWSTR; dwAccessType: DWORD;
      pwszProxyName: LPCWSTR; pwszProxyBypass: LPCWSTR; dwFlags: DWORD): HINTERNET;
      stdcall; external LIB_WINHTTPDLL Name 'WinHttpOpen';
    function WinHttpOpenRequest(hConnect: HINTERNET; pwszVerb: LPCWSTR;
      pwszObjectName: LPCWSTR; pwszVersion: LPCWSTR; pwszReferrer: LPCWSTR;
      ppwszAcceptTypes: LPCWSTR; dwFlags: DWORD): HINTERNET; stdcall;
      external LIB_WINHTTPDLL Name 'WinHttpOpenRequest';
    function WinHttpQueryAuthParams(hRequest: HINTERNET; AuthScheme: DWORD;
      pAuthParams: LPVOID): WINBOOL; stdcall;
      external LIB_WINHTTPDLL Name 'WinHttpQueryAuthParams';
    function WinHttpQueryAuthSchemes(hRequest: HINTERNET; lpdwSupportedSchemes: LPDWORD;
      lpdwFirstScheme: LPDWORD; pdwAuthTarget: LPDWORD): WINBOOL; stdcall;
      external LIB_WINHTTPDLL Name 'WinHttpQueryAuthSchemes';
    function WinHttpQueryDataAvailable(hRequest: HINTERNET;
      lpdwNumberOfBytesAvailable: LPDWORD): WINBOOL; stdcall;
      external LIB_WINHTTPDLL Name 'WinHttpQueryDataAvailable';
    function WinHttpQueryHeaders(hRequest: HINTERNET; dwInfoLevel: DWORD;
      pwszName: LPCWSTR; lpBuffer: LPVOID; lpdwBufferLength: LPDWORD;
      lpdwIndex: LPDWORD): WINBOOL; stdcall;
      external LIB_WINHTTPDLL Name 'WinHttpQueryHeaders';
    function WinHttpQueryOption(hInterneth: HINTERNET; dwOption: DWORD;
      lpBuffer: LPVOID; lpdwBufferLength: LPDWORD): WINBOOL; stdcall;
      external LIB_WINHTTPDLL Name 'WinHttpQueryOption';
    function WinHttpReadData(hRequest: HINTERNET; lpBuffer: LPVOID;
      dwNumberOfBytesToRead: DWORD; lpdwNumberOfBytesRead: LPDWORD): WINBOOL;
      stdcall; external LIB_WINHTTPDLL Name 'WinHttpReadData';
    function WinHttpReceiveResponse(hRequest: HINTERNET; lpReserved: LPVOID): WINBOOL;
      stdcall; external LIB_WINHTTPDLL Name 'WinHttpReceiveResponse';
    function WinHttpSendRequest(hRequest: HINTERNET; pwszHeaders: LPCWSTR;
      dwHeadersLength: DWORD; lpOptional: LPVOID; dwOptionalLength: DWORD;
      dwTotalLength: DWORD; dwContext: DWORD_PTR): WINBOOL; stdcall;
      external LIB_WINHTTPDLL Name 'WinHttpSendRequest';
    function WinHttpSetDefaultProxyConfiguration(pProxyInfo: PWINHTTP_PROXY_INFO): WINBOOL;
      stdcall; external LIB_WINHTTPDLL Name 'WinHttpSetDefaultProxyConfiguration';
    function WinHttpSetCredentials(hRequest: HINTERNET; AuthTargets: DWORD;
      AuthScheme: DWORD; pwszUserName: LPCWSTR; pwszPassword: LPCWSTR;
      pAuthParams: LPVOID): WINBOOL; stdcall;
      external LIB_WINHTTPDLL Name 'WinHttpSetCredentials';
    function WinHttpSetOption(hInterneth: HINTERNET; dwOption: DWORD;
      lpBuffer: LPVOID; dwBufferLength: DWORD): WINBOOL; stdcall;
      external LIB_WINHTTPDLL Name 'WinHttpSetOption';
    function WinHttpSetStatusCallback(hInterneth: HINTERNET;
      lpfnInternetCallback: WINHTTP_STATUS_CALLBACK; dwNotificationFlags: DWORD;
      dwReserved: DWORD_PTR): WINHTTP_STATUS_CALLBACK; stdcall;
      external LIB_WINHTTPDLL Name 'WinHttpSetStatusCallback';
    function WinHttpSetTimeouts(hInterneth: HINTERNET; dwResolveTimeout: longint;
      dwConnectTimeout: longint; dwSendTimeout: longint; dwReceiveTimeout: longint): WINBOOL;
      stdcall; external LIB_WINHTTPDLL Name 'WinHttpSetTimeouts';
    function WinHttpTimeFromSystemTime(pst: PSYSTEMTIME; pwszTime: LPWSTR): WINBOOL;
      stdcall; external LIB_WINHTTPDLL Name 'WinHttpTimeFromSystemTime';
    function WinHttpTimeToSystemTime(pwszTime: LPCWSTR; pst: PSYSTEMTIME): WINBOOL;
      stdcall; external LIB_WINHTTPDLL Name 'WinHttpTimeToSystemTime';
    function WinHttpWriteData(hRequest: HINTERNET; lpBuffer: LPCVOID;
      dwNumberOfBytesToWrite: DWORD; lpdwNumberOfBytesWritten: LPDWORD): WINBOOL;
      stdcall; external LIB_WINHTTPDLL Name 'WinHttpWriteData';
    
    implementation
    
    function WINHTTP_INVALID_STATUS_CALLBACK: WINHTTP_STATUS_CALLBACK;
    begin
      WINHTTP_INVALID_STATUS_CALLBACK := WINHTTP_STATUS_CALLBACK(-(1));
    end;
    
    end.
    
    winhttp.3.pas (28,257 bytes)

Relationships

related to 0036106 closedMichael Van Canneyt WinHTTP.h header translation 

Activities

Michal Gawrycki

2016-09-26 14:53

reporter  

winhttp.pas (44,059 bytes)
unit winhttp;

interface

uses
  Windows;

{*
 * Set up Structure Packing to be 4 bytes for all winhttp structures
 *}
 {$ifdef win64}
   {$packrecords 8}
 {$else}
   {$packrecords 4}
 {$endif}

const
  Winhttpdll = 'Winhttp.dll';

//
// types
//
type
  HINTERNET = Pointer;
  PHINTERNET = ^HINTERNET;
  LPHINTERNET = PHINTERNET;

  INTERNET_PORT = WORD;
  PINTERNET_PORT = ^INTERNET_PORT;
  LPINTERNET_PORT = PINTERNET_PORT;

//
// manifests
//
const

  INTERNET_DEFAULT_PORT         = 0;           // use the protocol-specific default
  INTERNET_DEFAULT_HTTP_PORT    = 80;          //    "     "  HTTP   "
  INTERNET_DEFAULT_HTTPS_PORT   = 443;         //    "     "  HTTPS  "

// flags for WinHttpOpen():
  WINHTTP_FLAG_ASYNC            = $10000000;   // this session is asynchronous (where supported)

// flags for WinHttpOpenRequest():
  WINHTTP_FLAG_SECURE               = $00800000;  // use SSL if applicable (HTTPS)
  WINHTTP_FLAG_ESCAPE_PERCENT       = $00000004;  // if escaping enabled, escape percent as well
  WINHTTP_FLAG_NULL_CODEPAGE        = $00000008;  // assume all symbols are ASCII, use fast convertion
  WINHTTP_FLAG_BYPASS_PROXY_CACHE   = $00000100;  // add "pragma: no-cache" request header
  WINHTTP_FLAG_REFRESH              = WINHTTP_FLAG_BYPASS_PROXY_CACHE;
  WINHTTP_FLAG_ESCAPE_DISABLE       = $00000040;  // disable escaping
  WINHTTP_FLAG_ESCAPE_DISABLE_QUERY = $00000080;  // if escaping enabled escape path part, but do not escape query


  SECURITY_FLAG_IGNORE_UNKNOWN_CA        = $00000100;
  SECURITY_FLAG_IGNORE_CERT_DATE_INVALID = $00002000; // expired X509 Cert.
  SECURITY_FLAG_IGNORE_CERT_CN_INVALID   = $00001000; // bad common name in X509 Cert.
  SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE  = $00000200;


//
// WINHTTP_ASYNC_RESULT - this structure is returned to the application via
// the callback with WINHTTP_CALLBACK_STATUS_REQUEST_COMPLETE. It is not sufficient to
// just return the result of the async operation. If the API failed then the
// app cannot call GetLastError() because the thread context will be incorrect.
// Both the value returned by the async API and any resultant error code are
// made available. The app need not check dwError if dwResult indicates that
// the API succeeded (in this case dwError will be ERROR_SUCCESS)
//

type
  PWinHttpAsyncResult = ^TWinHttpAsyncResult;
  WINHTTP_ASYNC_RESULT = record
    dwResult: DWORD_PTR;  // indicates which async API has encountered an error
    dwError: DWORD;       // the error code if the API failed
  end;
  TWinHttpAsyncResult = WINHTTP_ASYNC_RESULT;

//
// HTTP_VERSION_INFO - query or set global HTTP version (1.0 or 1.1)
//

  PHttpVersionInfo = ^THttpVersionInfo;
  HTTP_VERSION_INFO = record
    dwMajorVersion: DWORD;
    dwMinorVersion: DWORD;
  end;
  THttpVersionInfo = HTTP_VERSION_INFO;

//
// INTERNET_SCHEME - URL scheme type
//

  INTERNET_SCHEME = Integer;
  TInternetScheme = INTERNET_SCHEME;
  PInternetScheme = ^TInternetScheme;

const
  INTERNET_SCHEME_HTTP      = (1);
  INTERNET_SCHEME_HTTPS     = (2);


//
// URL_COMPONENTS - the constituent parts of an URL. Used in WinHttpCrackUrl()
// and WinHttpCreateUrl()
//
// For WinHttpCrackUrl(), if a pointer field and its corresponding length field
// are both 0 then that component is not returned. If the pointer field is NULL
// but the length field is not zero, then both the pointer and length fields are
// returned if both pointer and corresponding length fields are non-zero then
// the pointer field points to a buffer where the component is copied. The
// component may be un-escaped, depending on dwFlags
//
// For WinHttpCreateUrl(), the pointer fields should be NULL if the component
// is not required. If the corresponding length field is zero then the pointer
// field is the address of a zero-terminated string. If the length field is not
// zero then it is the string length of the corresponding pointer field
//

//#pragma warning( disable : 4121 )   // disable alignment warning

type
  PURLComponents = ^TURLComponents;
  URL_COMPONENTS = record
    dwStructSize: DWORD;       // size of this structure. Used in version check
    lpszScheme: LPWSTR;        // pointer to scheme name
    dwSchemeLength: DWORD;     // length of scheme name
    nScheme: TInternetScheme;  // enumerated scheme type (if known)
    lpszHostName: LPWSTR;      // pointer to host name
    dwHostNameLength: DWORD;   // length of host name
    nPort: INTERNET_PORT;      // converted port number
    lpszUserName: LPWSTR;      // pointer to user name
    dwUserNameLength: DWORD;   // length of user name
    lpszPassword: LPWSTR;      // pointer to password
    dwPasswordLength: DWORD;   // length of password
    lpszUrlPath: LPWSTR;       // pointer to URL-path
    dwUrlPathLength: DWORD;    // length of URL-path
    lpszExtraInfo: LPWSTR;     // pointer to extra information (e.g. ?foo or #foo)
    dwExtraInfoLength: DWORD;  // length of extra information
  end;
  TURLComponents = URL_COMPONENTS;

  TURLComponentsW = TURLComponents;
  PURLComponentsW = PURLComponents;

//#pragma warning( default : 4121 )   // restore alignment warning

//
// WINHTTP_PROXY_INFO - structure supplied with WINHTTP_OPTION_PROXY to get/
// set proxy information on a WinHttpOpen() handle
//

  PWinHttpProxyInfo = ^TWinHttpProxyInfo;
  WINHTTP_PROXY_INFO = record
    dwAccessType: DWORD;       // see WINHTTP_ACCESS_* types below
    lpszProxy: LPWSTR;         // proxy server list
    lpszProxyBypass: LPWSTR;   // proxy bypass list
  end;
  TWinHttpProxyInfo = WINHTTP_PROXY_INFO;

  TWinHttpProxyInfoW = TWinHttpProxyInfo;
  PWinHttpProxyInfoW = PWinHttpProxyInfo;

  PWinHttpAutoProxyOptions = ^TWinHttpAutoProxyOptions;
  WINHTTP_AUTOPROXY_OPTIONS = record
    dwFlags: DWORD;
    dwAutoDetectFlags: DWORD;
    lpszAutoConfigUrl: LPCWSTR;
    lpvReserved: Pointer;
    dwReserved: WORD;
    fAutoLogonIfChallenged: BOOL;
  end;
  TWinHttpAutoProxyOptions = WINHTTP_AUTOPROXY_OPTIONS;

const
  WINHTTP_AUTOPROXY_AUTO_DETECT         = $00000001;
  WINHTTP_AUTOPROXY_CONFIG_URL          = $00000002;
  WINHTTP_AUTOPROXY_RUN_INPROCESS       = $00010000;
  WINHTTP_AUTOPROXY_RUN_OUTPROCESS_ONLY = $00020000;
//
// Flags for dwAutoDetectFlags
//
  WINHTTP_AUTO_DETECT_TYPE_DHCP         = $00000001;
  WINHTTP_AUTO_DETECT_TYPE_DNS_A        = $00000002;


//
// WINHTTP_CERTIFICATE_INFO lpBuffer - contains the certificate returned from
// the server
//
type
  WINHTTP_CERTIFICATE_INFO = record
    //
    // ftExpiry - date the certificate expires.
    //

    ftExpiry: TFileTime;

    //
    // ftStart - date the certificate becomes valid.
    //

    ftStart: TFileTime;

    //
    // lpszSubjectInfo - the name of organization, site, and server
    //   the cert. was issued for.
    //

    lpszSubjectInfo: LPWSTR;

    //
    // lpszIssuerInfo - the name of orgainzation, site, and server
    //   the cert was issues by.
    //

    lpszIssuerInfo: LPWSTR;

    //
    // lpszProtocolName - the name of the protocol used to provide the secure
    //   connection.
    //

    lpszProtocolName: LPWSTR;

    //
    // lpszSignatureAlgName - the name of the algorithm used for signing
    //  the certificate.
    //

    lpszSignatureAlgName: LPWSTR;

    //
    // lpszEncryptionAlgName - the name of the algorithm used for
    //  doing encryption over the secure channel (SSL) connection.
    //

    lpszEncryptionAlgName: LPWSTR;

    //
    // dwKeySize - size of the key.
    //

    dwKeySize: DWORD;

  end;
  TWinHttpCertificateInfo = WINHTTP_CERTIFICATE_INFO;

{#ifdef _WS2DEF_

  WINHTTP_CONNECTION_INFO = record
    cbSize: DWORD;
    LocalAddress: SOCKADDR_STORAGE;  // local ip, local port
    RemoteAddress: SOCKADDR_STORAGE; // remote ip, remote port
  end;
  TWinHttpConnectionInfo = WINHTTP_CONNECTION_INFO;

#endif}

//
// prototypes
//

//
// constants for WinHttpTimeFromSystemTime
//
const
  WINHTTP_TIME_FORMAT_BUFSIZE  = 62;


function WinHttpTimeFromSystemTime
(
   pst: PSystemTime; // input GMT time
   pwszTime: LPWSTR  // output string buffer
): BOOL; stdcall; external Winhttpdll name 'WinHttpTimeFromSystemTime';

function WinHttpTimeToSystemTime
(
   pwszTime: LPCWSTR;      // NULL terminated string
   pst: PSystemTime        // output in GMT time
): BOOL; stdcall; external Winhttpdll name 'WinHttpTimeToSystemTime';


//
// flags for CrackUrl() and CombineUrl()
//
const
  ICU_NO_ENCODE          = $20000000;  // Don't convert unsafe characters to escape sequence
  ICU_DECODE             = $10000000;  // Convert %XX escape sequences to characters
  ICU_NO_META            = $08000000;  // Don't convert .. etc. meta path sequences
  ICU_ENCODE_SPACES_ONLY = $04000000;  // Encode spaces only
  ICU_BROWSER_MODE       = $02000000;  // Special encode/decode rules for browser
  ICU_ENCODE_PERCENT     = $00001000;  // Encode any percent (ASCII25)

  // signs encountered, default is to not encode percent.


function WinHttpCrackUrl
(
   pwszUrl: LPCWSTR;
   dwUrlLength: DWORD;
   dwFlags: DWORD;
   lpUrlComponents: PURLComponents
): BOOL; stdcall; external Winhttpdll name 'WinHttpCrackUrl';

function WinHttpCreateUrl
(
   lpUrlComponents: PURLComponents;
   dwFlags: DWORD;
   pwszUrl: LPWSTR;
   lpdwUrlLength: LPDWORD
): BOOL; stdcall; external Winhttpdll name 'WinHttpCreateUrl';

//
// flags for WinHttpCrackUrl() and WinHttpCreateUrl()
//
const
  ICU_ESCAPE           = DWORD($80000000); // (un)escape URL characters
  ICU_ESCAPE_AUTHORITY = $00002000;  // causes InternetCreateUrlA to escape chars in authority components (user, pwd, host)
  ICU_REJECT_USERPWD   = $00004000;  // rejects usrls whick have username/pwd sections

function WinHttpCheckPlatform: BOOL; cdecl; external Winhttpdll name 'WinHttpCheckPlatform';

function WinHttpGetDefaultProxyConfiguration(pProxyInfo: PWinHttpProxyInfo): BOOL; stdcall; external Winhttpdll name 'WinHttpGetDefaultProxyConfiguration';
function WinHttpSetDefaultProxyConfiguration(pProxyInfo: PWinHttpProxyInfo): BOOL; stdcall; external Winhttpdll name 'WinHttpDefaultProxyConfiguration';


function WinHttpOpen
(
   pszAgentW: LPCWSTR;
   dwAccessType: DWORD;
   pszProxyW: LPCWSTR;
   pszProxyBypassW: LPCWSTR;
   dwFlags: DWORD
): HINTERNET; stdcall; external Winhttpdll name 'WinHttpOpen';

// WinHttpOpen dwAccessType values (also for WINHTTP_PROXY_INFO::dwAccessType)
const
  WINHTTP_ACCESS_TYPE_DEFAULT_PROXY             = 0;
  WINHTTP_ACCESS_TYPE_NO_PROXY                  = 1;
  WINHTTP_ACCESS_TYPE_NAMED_PROXY               = 3;

// WinHttpOpen prettifiers for optional parameters
  WINHTTP_NO_PROXY_NAME    = nil;
  WINHTTP_NO_PROXY_BYPASS  = nil;


function WinHttpCloseHandle
(
   hInternet: HINTERNET
): BOOL; stdcall; external Winhttpdll name 'WinHttpCloseHandle';


function WinHttpConnect
(
   hSession: HINTERNET;
   pswzServerName: LPCWSTR;
   nServerPort: INTERNET_PORT;
   dwReserved: DWORD
): HINTERNET; stdcall; external Winhttpdll name 'WinHttpConnect';


function WinHttpReadData
(
   hRequest: HINTERNET;
   lpBuffer: Pointer;
   dwNumberOfBytesToRead: DWORD;
   lpdwNumberOfBytesRead: LPDWORD
): BOOL; stdcall; external Winhttpdll name 'WinHttpReadData';


function WinHttpWriteData
(
   hRequest: HINTERNET;
   lpBuffer: Pointer;
   dwNumberOfBytesToWrite: DWORD;
   lpdwNumberOfBytesWritten: LPDWORD
): BOOL; stdcall; external Winhttpdll name 'WinHttpWriteData';


function WinHttpQueryDataAvailable
(
   hRequest: HINTERNET;
   lpdwNumberOfBytesAvailable: LPDWORD
): BOOL; stdcall; external Winhttpdll name 'WinHttpQueryDataAvailable';


function WinHttpQueryOption
(
   hInternet: HINTERNET;
   dwOption: DWORD;
   lpBuffer: Pointer;
   lpdwBufferLength: LPDWORD
): BOOL; stdcall; external Winhttpdll name 'WinHttpQueryOption';

const
  WINHTTP_NO_CLIENT_CERT_CONTEXT = nil;

function WinHttpSetOption
(
   hInternet: HINTERNET;
   dwOption: DWORD;
   lpBuffer: Pointer;
   dwBufferLength: DWORD
): BOOL; stdcall; external Winhttpdll name 'WinHttpSetOption';


function WinHttpSetTimeouts
(
   hInternet: HINTERNET;           // Session/Request handle.
   nResolveTimeout: Integer;
   nConnectTimeout: Integer;
   nSendTimeout: Integer;
   nReceiveTimeout: Integer
): BOOL; stdcall; external Winhttpdll name 'WinHttpSetTimeouts';

//
// options manifests for WinHttp{Query|Set}Option
//
const
  WINHTTP_FIRST_OPTION                         =  1; //WINHTTP_OPTION_CALLBACK;

  WINHTTP_OPTION_CALLBACK                      =  1;
  WINHTTP_OPTION_RESOLVE_TIMEOUT               =  2;
  WINHTTP_OPTION_CONNECT_TIMEOUT               =  3;
  WINHTTP_OPTION_CONNECT_RETRIES               =  4;
  WINHTTP_OPTION_SEND_TIMEOUT                  =  5;
  WINHTTP_OPTION_RECEIVE_TIMEOUT               =  6;
  WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT      =  7;
  WINHTTP_OPTION_HANDLE_TYPE                   =  9;
  WINHTTP_OPTION_READ_BUFFER_SIZE              = 12;
  WINHTTP_OPTION_WRITE_BUFFER_SIZE             = 13;
  WINHTTP_OPTION_PARENT_HANDLE                 = 21;
  WINHTTP_OPTION_EXTENDED_ERROR                = 24;
  WINHTTP_OPTION_SECURITY_FLAGS                = 31;
  WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT   = 32;
  WINHTTP_OPTION_URL                           = 34;
  WINHTTP_OPTION_SECURITY_KEY_BITNESS          = 36;
  WINHTTP_OPTION_PROXY                         = 38;


  WINHTTP_OPTION_USER_AGENT                    = 41;
  WINHTTP_OPTION_CONTEXT_VALUE                 = 45;
  WINHTTP_OPTION_CLIENT_CERT_CONTEXT           = 47;
  WINHTTP_OPTION_REQUEST_PRIORITY              = 58;
  WINHTTP_OPTION_HTTP_VERSION                  = 59;
  WINHTTP_OPTION_DISABLE_FEATURE               = 63;

  WINHTTP_OPTION_CODEPAGE                      = 68;
  WINHTTP_OPTION_MAX_CONNS_PER_SERVER          = 73;
  WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER      = 74;
  WINHTTP_OPTION_AUTOLOGON_POLICY              = 77;
  WINHTTP_OPTION_SERVER_CERT_CONTEXT           = 78;
  WINHTTP_OPTION_ENABLE_FEATURE                = 79;
  WINHTTP_OPTION_WORKER_THREAD_COUNT           = 80;
  WINHTTP_OPTION_PASSPORT_COBRANDING_TEXT      = 81;
  WINHTTP_OPTION_PASSPORT_COBRANDING_URL       = 82;
  WINHTTP_OPTION_CONFIGURE_PASSPORT_AUTH       = 83;
  WINHTTP_OPTION_SECURE_PROTOCOLS              = 84;
  WINHTTP_OPTION_ENABLETRACING                 = 85;
  WINHTTP_OPTION_PASSPORT_SIGN_OUT             = 86;
  WINHTTP_OPTION_PASSPORT_RETURN_URL           = 87;
  WINHTTP_OPTION_REDIRECT_POLICY               = 88;
  WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS  = 89;
  WINHTTP_OPTION_MAX_HTTP_STATUS_CONTINUE      = 90;
  WINHTTP_OPTION_MAX_RESPONSE_HEADER_SIZE      = 91;
  WINHTTP_OPTION_MAX_RESPONSE_DRAIN_SIZE       = 92;
  WINHTTP_OPTION_CONNECTION_INFO               = 93;
  WINHTTP_OPTION_CLIENT_CERT_ISSUER_LIST       = 94;
  WINHTTP_OPTION_SPN                           = 96;

  WINHTTP_OPTION_GLOBAL_PROXY_CREDS            = 97;
  WINHTTP_OPTION_GLOBAL_SERVER_CREDS           = 98;

  WINHTTP_OPTION_UNLOAD_NOTIFY_EVENT           = 99;
  WINHTTP_OPTION_REJECT_USERPWD_IN_URL         = 100;
  WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS = 101;


  WINHTTP_LAST_OPTION                          = WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS;

  WINHTTP_OPTION_USERNAME                      = $1000;
  WINHTTP_OPTION_PASSWORD                      = $1001;
  WINHTTP_OPTION_PROXY_USERNAME                = $1002;
  WINHTTP_OPTION_PROXY_PASSWORD                = $1003;


// manifest value for WINHTTP_OPTION_MAX_CONNS_PER_SERVER and WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER
  WINHTTP_CONNS_PER_SERVER_UNLIMITED   = DWORD($FFFFFFFF);


// values for WINHTTP_OPTION_AUTOLOGON_POLICY
  WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM  = 0;
  WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW     = 1;
  WINHTTP_AUTOLOGON_SECURITY_LEVEL_HIGH    = 2;

  WINHTTP_AUTOLOGON_SECURITY_LEVEL_DEFAULT      = WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM;

// values for WINHTTP_OPTION_REDIRECT_POLICY
  WINHTTP_OPTION_REDIRECT_POLICY_NEVER                      = 0;
  WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP     = 1;
  WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS                     = 2;

  WINHTTP_OPTION_REDIRECT_POLICY_LAST          = WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS;
  WINHTTP_OPTION_REDIRECT_POLICY_DEFAULT       = WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP;

  WINHTTP_DISABLE_PASSPORT_AUTH    = $00000000;
  WINHTTP_ENABLE_PASSPORT_AUTH     = $10000000;
  WINHTTP_DISABLE_PASSPORT_KEYRING = $20000000;
  WINHTTP_ENABLE_PASSPORT_KEYRING  = $40000000;


// values for WINHTTP_OPTION_DISABLE_FEATURE
  WINHTTP_DISABLE_COOKIES                 = $00000001;
  WINHTTP_DISABLE_REDIRECTS               = $00000002;
  WINHTTP_DISABLE_AUTHENTICATION          = $00000004;
  WINHTTP_DISABLE_KEEP_ALIVE              = $00000008;

// values for WINHTTP_OPTION_ENABLE_FEATURE
  WINHTTP_ENABLE_SSL_REVOCATION           = $00000001;
  WINHTTP_ENABLE_SSL_REVERT_IMPERSONATION = $00000002;

// values for WINHTTP_OPTION_SPN
  WINHTTP_DISABLE_SPN_SERVER_PORT         = $00000000;
  WINHTTP_ENABLE_SPN_SERVER_PORT          = $00000001;
  WINHTTP_OPTION_SPN_MASK                 = WINHTTP_ENABLE_SPN_SERVER_PORT;
type
  PWinHttpCreds = ^TWinHttpCreds;
  tagWINHTTP_CREDS = record
    lpszUserName: LPSTR;
    lpszPassword: LPSTR;
    lpszRealm: LPSTR;
    dwAuthScheme: DWORD;
    lpszHostName: LPSTR;
    dwPort: DWORD;
  end;
  TWinHttpCreds = tagWINHTTP_CREDS;

  WINHTTP_CREDS = tagWINHTTP_CREDS;
  PWINHTTP_CREDS = ^tagWINHTTP_CREDS;

// structure for WINHTTP_OPTION_GLOBAL_SERVER_CREDS and
// WINHTTP_OPTION_GLOBAL_PROXY_CREDS
  PWinHttpCredsEx = ^TWinHttpCredsEx;
  tagWINHTTP_CREDS_EX = record
    lpszUserName: LPSTR;
    lpszPassword: LPSTR;
    lpszRealm: LPSTR;
    dwAuthScheme: DWORD;
    lpszHostName: DWORD;
    dwPort: DWORD;
    lpszUrl: LPSTR;
  end;
  TWinHttpCredsEx = tagWINHTTP_CREDS_EX;

  WINHTTP_CREDS_EX = tagWINHTTP_CREDS_EX;
  PWINHTTP_CREDS_EX = ^tagWINHTTP_CREDS_EX;

//
// winhttp handle types
//
const
  WINHTTP_HANDLE_TYPE_SESSION                = 1;
  WINHTTP_HANDLE_TYPE_CONNECT                = 2;
  WINHTTP_HANDLE_TYPE_REQUEST                = 3;

//
// values for auth schemes
//
  WINHTTP_AUTH_SCHEME_BASIC     = $00000001;
  WINHTTP_AUTH_SCHEME_NTLM      = $00000002;
  WINHTTP_AUTH_SCHEME_PASSPORT  = $00000004;
  WINHTTP_AUTH_SCHEME_DIGEST    = $00000008;
  WINHTTP_AUTH_SCHEME_NEGOTIATE = $00000010;

// WinHttp supported Authentication Targets

  WINHTTP_AUTH_TARGET_SERVER = $00000000;
  WINHTTP_AUTH_TARGET_PROXY  = $00000001;

//
// values for WINHTTP_OPTION_SECURITY_FLAGS
//

// query only
  SECURITY_FLAG_SECURE                  = $00000001; // can query only
  SECURITY_FLAG_STRENGTH_WEAK           = $10000000;
  SECURITY_FLAG_STRENGTH_MEDIUM         = $40000000;
  SECURITY_FLAG_STRENGTH_STRONG         = $20000000;



// Secure connection error status flags
  WINHTTP_CALLBACK_STATUS_FLAG_CERT_REV_FAILED        = $00000001;
  WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CERT           = $00000002;
  WINHTTP_CALLBACK_STATUS_FLAG_CERT_REVOKED           = $00000004;
  WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CA             = $00000008;
  WINHTTP_CALLBACK_STATUS_FLAG_CERT_CN_INVALID        = $00000010;
  WINHTTP_CALLBACK_STATUS_FLAG_CERT_DATE_INVALID      = $00000020;
  WINHTTP_CALLBACK_STATUS_FLAG_CERT_WRONG_USAGE       = $00000040;
  WINHTTP_CALLBACK_STATUS_FLAG_SECURITY_CHANNEL_ERROR = DWORD($80000000);


  WINHTTP_FLAG_SECURE_PROTOCOL_SSL2 = $00000008;
  WINHTTP_FLAG_SECURE_PROTOCOL_SSL3 = $00000020;
  WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 = $00000080;
  WINHTTP_FLAG_SECURE_PROTOCOL_ALL  = (WINHTTP_FLAG_SECURE_PROTOCOL_SSL2 or
                                       WINHTTP_FLAG_SECURE_PROTOCOL_SSL3 or
                                       WINHTTP_FLAG_SECURE_PROTOCOL_TLS1);


//
// callback function for WinHttpSetStatusCallback
//
type
 {WINHTTP_STATUS_CALLBACK = procedure(
    hInternet: HINTERNET;
    dwContext: DWORD_PTR;
    dwInternetStatus: DWORD;
    lpvStatusInformation: Pointer;
    dwStatusInformationLength: DWORD); stdcall;

  TFNWinHttpStatusCallback = WINHTTP_STATUS_CALLBACK;
  PFNWinHttpStatusCallback = ^TFNWinHttpStatusCallback;}
  TFNWinHttpStatusCallback = TFarProc;

function WinHttpSetStatusCallback
(
   hInternet: HINTERNET;
   lpfnInternetCallback: TFNWinHttpStatusCallback;
   dwNotificationFlags: DWORD;
   dwReserved: DWORD_PTR
): TFNWinHttpStatusCallback; stdcall; external Winhttpdll name 'WinHttpSetStatusCallback';

//
// status manifests for WinHttp status callback
//
const
  WINHTTP_CALLBACK_STATUS_RESOLVING_NAME         = $00000001;
  WINHTTP_CALLBACK_STATUS_NAME_RESOLVED          = $00000002;
  WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER   = $00000004;
  WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER    = $00000008;
  WINHTTP_CALLBACK_STATUS_SENDING_REQUEST        = $00000010;
  WINHTTP_CALLBACK_STATUS_REQUEST_SENT           = $00000020;
  WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE     = $00000040;
  WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED      = $00000080;
  WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION     = $00000100;
  WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED      = $00000200;
  WINHTTP_CALLBACK_STATUS_HANDLE_CREATED         = $00000400;
  WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING         = $00000800;
  WINHTTP_CALLBACK_STATUS_DETECTING_PROXY        = $00001000;
  WINHTTP_CALLBACK_STATUS_REDIRECT               = $00004000;
  WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE  = $00008000;
  WINHTTP_CALLBACK_STATUS_SECURE_FAILURE         = $00010000;
  WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE      = $00020000;
  WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE         = $00040000;
  WINHTTP_CALLBACK_STATUS_READ_COMPLETE          = $00080000;
  WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE         = $00100000;
  WINHTTP_CALLBACK_STATUS_REQUEST_ERROR          = $00200000;
  WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE   = $00400000;


// API Enums for WINHTTP_CALLBACK_STATUS_REQUEST_ERROR:
  API_RECEIVE_RESPONSE         = (1);
  API_QUERY_DATA_AVAILABLE     = (2);
  API_READ_DATA                = (3);
  API_WRITE_DATA               = (4);
  API_SEND_REQUEST             = (5);


  WINHTTP_CALLBACK_FLAG_RESOLVE_NAME             = (WINHTTP_CALLBACK_STATUS_RESOLVING_NAME or WINHTTP_CALLBACK_STATUS_NAME_RESOLVED);
  WINHTTP_CALLBACK_FLAG_CONNECT_TO_SERVER        = (WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER or WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER);
  WINHTTP_CALLBACK_FLAG_SEND_REQUEST             = (WINHTTP_CALLBACK_STATUS_SENDING_REQUEST or WINHTTP_CALLBACK_STATUS_REQUEST_SENT);
  WINHTTP_CALLBACK_FLAG_RECEIVE_RESPONSE         = (WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE or WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED);
  WINHTTP_CALLBACK_FLAG_CLOSE_CONNECTION         = (WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION or WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED);
  WINHTTP_CALLBACK_FLAG_HANDLES                  = (WINHTTP_CALLBACK_STATUS_HANDLE_CREATED or WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING);
  WINHTTP_CALLBACK_FLAG_DETECTING_PROXY          = WINHTTP_CALLBACK_STATUS_DETECTING_PROXY;
  WINHTTP_CALLBACK_FLAG_REDIRECT                 = WINHTTP_CALLBACK_STATUS_REDIRECT;
  WINHTTP_CALLBACK_FLAG_INTERMEDIATE_RESPONSE    = WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE;
  WINHTTP_CALLBACK_FLAG_SECURE_FAILURE           = WINHTTP_CALLBACK_STATUS_SECURE_FAILURE;
  WINHTTP_CALLBACK_FLAG_SENDREQUEST_COMPLETE     = WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE;
  WINHTTP_CALLBACK_FLAG_HEADERS_AVAILABLE        = WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE;
  WINHTTP_CALLBACK_FLAG_DATA_AVAILABLE           = WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE;
  WINHTTP_CALLBACK_FLAG_READ_COMPLETE            = WINHTTP_CALLBACK_STATUS_READ_COMPLETE;
  WINHTTP_CALLBACK_FLAG_WRITE_COMPLETE           = WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE;
  WINHTTP_CALLBACK_FLAG_REQUEST_ERROR            = WINHTTP_CALLBACK_STATUS_REQUEST_ERROR;


  WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS          = (WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE or
                                                    WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE or
                                                    WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE or
                                                    WINHTTP_CALLBACK_STATUS_READ_COMPLETE or
                                                    WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE or
                                                    WINHTTP_CALLBACK_STATUS_REQUEST_ERROR);
  WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS        = DWORD($ffffffff);

//
// if the following value is returned by WinHttpSetStatusCallback, then
// probably an invalid (non-code) address was supplied for the callback
//

  WINHTTP_INVALID_STATUS_CALLBACK      = Pointer(-1);


//
// WinHttpQueryHeaders info levels. Generally, there is one info level
// for each potential RFC822/HTTP/MIME header that an HTTP server
// may send as part of a request response.
//
// The WINHTTP_QUERY_RAW_HEADERS info level is provided for clients
// that choose to perform their own header parsing.
//


  WINHTTP_QUERY_MIME_VERSION               = 0;
  WINHTTP_QUERY_CONTENT_TYPE               = 1;
  WINHTTP_QUERY_CONTENT_TRANSFER_ENCODING  = 2;
  WINHTTP_QUERY_CONTENT_ID                 = 3;
  WINHTTP_QUERY_CONTENT_DESCRIPTION        = 4;
  WINHTTP_QUERY_CONTENT_LENGTH             = 5;
  WINHTTP_QUERY_CONTENT_LANGUAGE           = 6;
  WINHTTP_QUERY_ALLOW                      = 7;
  WINHTTP_QUERY_PUBLIC                     = 8;
  WINHTTP_QUERY_DATE                       = 9;
  WINHTTP_QUERY_EXPIRES                    = 10;
  WINHTTP_QUERY_LAST_MODIFIED              = 11;
  WINHTTP_QUERY_MESSAGE_ID                 = 12;
  WINHTTP_QUERY_URI                        = 13;
  WINHTTP_QUERY_DERIVED_FROM               = 14;
  WINHTTP_QUERY_COST                       = 15;
  WINHTTP_QUERY_LINK                       = 16;
  WINHTTP_QUERY_PRAGMA                     = 17;
  WINHTTP_QUERY_VERSION                    = 18;  // special: part of status line
  WINHTTP_QUERY_STATUS_CODE                = 19;  // special: part of status line
  WINHTTP_QUERY_STATUS_TEXT                = 20;  // special: part of status line
  WINHTTP_QUERY_RAW_HEADERS                = 21;  // special: all headers as ASCIIZ
  WINHTTP_QUERY_RAW_HEADERS_CRLF           = 22;  // special: all headers
  WINHTTP_QUERY_CONNECTION                 = 23;
  WINHTTP_QUERY_ACCEPT                     = 24;
  WINHTTP_QUERY_ACCEPT_CHARSET             = 25;
  WINHTTP_QUERY_ACCEPT_ENCODING            = 26;
  WINHTTP_QUERY_ACCEPT_LANGUAGE            = 27;
  WINHTTP_QUERY_AUTHORIZATION              = 28;
  WINHTTP_QUERY_CONTENT_ENCODING           = 29;
  WINHTTP_QUERY_FORWARDED                  = 30;
  WINHTTP_QUERY_FROM                       = 31;
  WINHTTP_QUERY_IF_MODIFIED_SINCE          = 32;
  WINHTTP_QUERY_LOCATION                   = 33;
  WINHTTP_QUERY_ORIG_URI                   = 34;
  WINHTTP_QUERY_REFERER                    = 35;
  WINHTTP_QUERY_RETRY_AFTER                = 36;
  WINHTTP_QUERY_SERVER                     = 37;
  WINHTTP_QUERY_TITLE                      = 38;
  WINHTTP_QUERY_USER_AGENT                 = 39;
  WINHTTP_QUERY_WWW_AUTHENTICATE           = 40;
  WINHTTP_QUERY_PROXY_AUTHENTICATE         = 41;
  WINHTTP_QUERY_ACCEPT_RANGES              = 42;
  WINHTTP_QUERY_SET_COOKIE                 = 43;
  WINHTTP_QUERY_COOKIE                     = 44;
  WINHTTP_QUERY_REQUEST_METHOD             = 45;  // special: GET/POST etc.
  WINHTTP_QUERY_REFRESH                    = 46;
  WINHTTP_QUERY_CONTENT_DISPOSITION        = 47;

//
// HTTP 1.1 defined headers
//

  WINHTTP_QUERY_AGE                        = 48;
  WINHTTP_QUERY_CACHE_CONTROL              = 49;
  WINHTTP_QUERY_CONTENT_BASE               = 50;
  WINHTTP_QUERY_CONTENT_LOCATION           = 51;
  WINHTTP_QUERY_CONTENT_MD5                = 52;
  WINHTTP_QUERY_CONTENT_RANGE              = 53;
  WINHTTP_QUERY_ETAG                       = 54;
  WINHTTP_QUERY_HOST                       = 55;
  WINHTTP_QUERY_IF_MATCH                   = 56;
  WINHTTP_QUERY_IF_NONE_MATCH              = 57;
  WINHTTP_QUERY_IF_RANGE                   = 58;
  WINHTTP_QUERY_IF_UNMODIFIED_SINCE        = 59;
  WINHTTP_QUERY_MAX_FORWARDS               = 60;
  WINHTTP_QUERY_PROXY_AUTHORIZATION        = 61;
  WINHTTP_QUERY_RANGE                      = 62;
  WINHTTP_QUERY_TRANSFER_ENCODING          = 63;
  WINHTTP_QUERY_UPGRADE                    = 64;
  WINHTTP_QUERY_VARY                       = 65;
  WINHTTP_QUERY_VIA                        = 66;
  WINHTTP_QUERY_WARNING                    = 67;
  WINHTTP_QUERY_EXPECT                     = 68;
  WINHTTP_QUERY_PROXY_CONNECTION           = 69;
  WINHTTP_QUERY_UNLESS_MODIFIED_SINCE      = 70;



  WINHTTP_QUERY_PROXY_SUPPORT              = 75;
  WINHTTP_QUERY_AUTHENTICATION_INFO        = 76;
  WINHTTP_QUERY_PASSPORT_URLS              = 77;
  WINHTTP_QUERY_PASSPORT_CONFIG            = 78;

  WINHTTP_QUERY_MAX                        = 78;

//
// WINHTTP_QUERY_CUSTOM - if this special value is supplied as the dwInfoLevel
// parameter of WinHttpQueryHeaders() then the lpBuffer parameter contains the name
// of the header we are to query
//

  WINHTTP_QUERY_CUSTOM                     = 65535;

//
// WINHTTP_QUERY_FLAG_REQUEST_HEADERS - if this bit is set in the dwInfoLevel
// parameter of WinHttpQueryHeaders() then the request headers will be queried for the
// request information
//

  WINHTTP_QUERY_FLAG_REQUEST_HEADERS       = DWORD($80000000);

//
// WINHTTP_QUERY_FLAG_SYSTEMTIME - if this bit is set in the dwInfoLevel parameter
// of WinHttpQueryHeaders() AND the header being queried contains date information,
// e.g. the "Expires:" header then lpBuffer will contain a SYSTEMTIME structure
// containing the date and time information converted from the header string
//

  WINHTTP_QUERY_FLAG_SYSTEMTIME            = $40000000;

//
// WINHTTP_QUERY_FLAG_NUMBER - if this bit is set in the dwInfoLevel parameter of
// HttpQueryHeader(), then the value of the header will be converted to a number
// before being returned to the caller, if applicable
//

  WINHTTP_QUERY_FLAG_NUMBER                = $20000000;



//
// HTTP Response Status Codes:
//

  HTTP_STATUS_CONTINUE            = 100; // OK to continue with request
  HTTP_STATUS_SWITCH_PROTOCOLS    = 101; // server has switched protocols in upgrade header

  HTTP_STATUS_OK                  = 200; // request completed
  HTTP_STATUS_CREATED             = 201; // object created, reason = new URI
  HTTP_STATUS_ACCEPTED            = 202; // async completion (TBS)
  HTTP_STATUS_PARTIAL             = 203; // partial completion
  HTTP_STATUS_NO_CONTENT          = 204; // no info to return
  HTTP_STATUS_RESET_CONTENT       = 205; // request completed, but clear form
  HTTP_STATUS_PARTIAL_CONTENT     = 206; // partial GET fulfilled
  HTTP_STATUS_WEBDAV_MULTI_STATUS = 207; // WebDAV Multi-Status

  HTTP_STATUS_AMBIGUOUS           = 300; // server couldn't decide what to return
  HTTP_STATUS_MOVED               = 301; // object permanently moved
  HTTP_STATUS_REDIRECT            = 302; // object temporarily moved
  HTTP_STATUS_REDIRECT_METHOD     = 303; // redirection w/ new access method
  HTTP_STATUS_NOT_MODIFIED        = 304; // if-modified-since was not modified
  HTTP_STATUS_USE_PROXY           = 305; // redirection to proxy, location header specifies proxy to use
  HTTP_STATUS_REDIRECT_KEEP_VERB  = 307; // HTTP/1.1: keep same verb

  HTTP_STATUS_BAD_REQUEST         = 400; // invalid syntax
  HTTP_STATUS_DENIED              = 401; // access denied
  HTTP_STATUS_PAYMENT_REQ         = 402; // payment required
  HTTP_STATUS_FORBIDDEN           = 403; // request forbidden
  HTTP_STATUS_NOT_FOUND           = 404; // object not found
  HTTP_STATUS_BAD_METHOD          = 405; // method is not allowed
  HTTP_STATUS_NONE_ACCEPTABLE     = 406; // no response acceptable to client found
  HTTP_STATUS_PROXY_AUTH_REQ      = 407; // proxy authentication required
  HTTP_STATUS_REQUEST_TIMEOUT     = 408; // server timed out waiting for request
  HTTP_STATUS_CONFLICT            = 409; // user should resubmit with more info
  HTTP_STATUS_GONE                = 410; // the resource is no longer available
  HTTP_STATUS_LENGTH_REQUIRED     = 411; // the server refused to accept request w/o a length
  HTTP_STATUS_PRECOND_FAILED      = 412; // precondition given in request failed
  HTTP_STATUS_REQUEST_TOO_LARGE   = 413; // request entity was too large
  HTTP_STATUS_URI_TOO_LONG        = 414; // request URI too long
  HTTP_STATUS_UNSUPPORTED_MEDIA   = 415; // unsupported media type
  HTTP_STATUS_RETRY_WITH          = 449; // retry after doing the appropriate action.

  HTTP_STATUS_SERVER_ERROR        = 500; // internal server error
  HTTP_STATUS_NOT_SUPPORTED       = 501; // required not supported
  HTTP_STATUS_BAD_GATEWAY         = 502; // error response received from gateway
  HTTP_STATUS_SERVICE_UNAVAIL     = 503; // temporarily overloaded
  HTTP_STATUS_GATEWAY_TIMEOUT     = 504; // timed out waiting for gateway
  HTTP_STATUS_VERSION_NOT_SUP     = 505; // HTTP version not supported

  HTTP_STATUS_FIRST               = HTTP_STATUS_CONTINUE;
  HTTP_STATUS_LAST                = HTTP_STATUS_VERSION_NOT_SUP;

//
// prototypes
//

function WinHttpOpenRequest
(
   hConnect: HINTERNET;
   pwszVerb: LPCWSTR;
   pwszObjectName: LPCWSTR;
   pwszVersion: LPCWSTR;
   pwszReferrer: LPCWSTR;
   ppwszAcceptTypes: LPCWSTR; //LPCWSTR FAR *
   dwFlags: DWORD
): HINTERNET;  stdcall; external Winhttpdll name 'WinHttpOpenRequest';

// WinHttpOpenRequest prettifers for optional parameters
const
  WINHTTP_NO_REFERER            = nil;
  WINHTTP_DEFAULT_ACCEPT_TYPES  = nil;

function WinHttpAddRequestHeaders
(
   hRequest: HINTERNET;
   pwszHeaders: LPCWSTR;
   dwHeadersLength: DWORD;
   dwModifiers: DWORD
): BOOL; stdcall; external Winhttpdll name 'WinHttpAddRequestHeaders';

//
// values for dwModifiers parameter of WinHttpAddRequestHeaders()
//
const
  WINHTTP_ADDREQ_INDEX_MASK      = $0000FFFF;
  WINHTTP_ADDREQ_FLAGS_MASK      = DWORD($FFFF0000);

//
// WINHTTP_ADDREQ_FLAG_ADD_IF_NEW - the header will only be added if it doesn't
// already exist
//

  WINHTTP_ADDREQ_FLAG_ADD_IF_NEW = $10000000;

//
// WINHTTP_ADDREQ_FLAG_ADD - if WINHTTP_ADDREQ_FLAG_REPLACE is set but the header is
// not found then if this flag is set, the header is added anyway, so long as
// there is a valid header-value
//

  WINHTTP_ADDREQ_FLAG_ADD        = $20000000;

//
// WINHTTP_ADDREQ_FLAG_COALESCE - coalesce headers with same name. e.g.
// "Accept: text/*" and "Accept: audio/*" with this flag results in a single
// header: "Accept: text/*, audio/*"
//

  WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA     = $40000000;
  WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON = $01000000;
  WINHTTP_ADDREQ_FLAG_COALESCE                = WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA;

//
// WINHTTP_ADDREQ_FLAG_REPLACE - replaces the specified header. Only one header can
// be supplied in the buffer. If the header to be replaced is not the first
// in a list of headers with the same name, then the relative index should be
// supplied in the low 8 bits of the dwModifiers parameter. If the header-value
// part is missing, then the header is removed
//

  WINHTTP_ADDREQ_FLAG_REPLACE  = DWORD($80000000);

  WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH = 0;

function WinHttpSendRequest
(
   hRequest: HINTERNET;
   pwszHeaders: LPCWSTR;
   dwHeadersLength: DWORD;
   lpOptional: Pointer;
   dwOptionalLength: DWORD;
   dwTotalLength: DWORD;
   dwContext: DWORD_PTR
): BOOL; stdcall; external Winhttpdll name 'WinHttpSendRequest';

// WinHttpSendRequest prettifiers for optional parameters.
const
  WINHTTP_NO_ADDITIONAL_HEADERS = nil;
  WINHTTP_NO_REQUEST_DATA       = nil;


function WinHttpSetCredentials
(

   hRequest: HINTERNET;     // HINTERNET handle returned by WinHttpOpenRequest.


   AuthTargets: DWORD;      // Only WINHTTP_AUTH_TARGET_SERVER and
                            // WINHTTP_AUTH_TARGET_PROXY are supported
                            // in this version and they are mutually
                            // exclusive

   AuthScheme: DWORD;       // must be one of the supported Auth Schemes
                            // returned from WinHttpQueryAuthSchemes()

   pwszUserName: LPCWSTR;   // 1) NULL if default creds is to be used, in
                            // which case pszPassword will be ignored

   pwszPassword: LPCWSTR;   // 1) "" == Blank Password; 2)Parameter ignored
                            // if pszUserName is NULL; 3) Invalid to pass in
                            // NULL if pszUserName is not NULL
   pAuthParams: Pointer
): BOOL; stdcall; external Winhttpdll name 'WinHttpSetCredentials';


function WinHttpQueryAuthSchemes
(
   hRequest: HINTERNET;           // HINTERNET handle returned by WinHttpOpenRequest
   lpdwSupportedSchemes: LPDWORD; // a bitmap of available Authentication Schemes
   lpdwFirstScheme: LPDWORD;      // returns the first auth scheme returned by the server
   pdwAuthTarget: LPDWORD
): BOOL; stdcall; external Winhttpdll name 'WinHttpQueryAuthSchemes';

function WinHttpQueryAuthParams(
   hRequest: HINTERNET;        // HINTERNET handle returned by WinHttpOpenRequest
   AuthScheme: DWORD;
   pAuthParams: Pointer        // Scheme-specific Advanced auth parameters
): BOOL; stdcall; external Winhttpdll name 'WinHttpQueryAuthParams';

function WinHttpReceiveResponse
(
   hRequest: HINTERNET;
   lpReserved: Pointer
): BOOL; stdcall; external Winhttpdll name 'WinHttpReceiveResponse';



function WinHttpQueryHeaders
(
   hRequest: HINTERNET;
   dwInfoLevel: DWORD;
   pwszName: LPCWSTR;
   lpBuffer: Pointer;
   lpdwBufferLength: LPDWORD;
   lpdwIndex: LPDWORD
): BOOL; stdcall; external Winhttpdll name 'WinHttpQueryHeaders';

// WinHttpQueryHeaders prettifiers for optional parameters.
const
  WINHTTP_HEADER_NAME_BY_INDEX         = nil;
  WINHTTP_NO_OUTPUT_BUFFER             = nil;
  WINHTTP_NO_HEADER_INDEX              = nil;

function WinHttpDetectAutoProxyConfigUrl
(
   dwAutoDetectFlags: DWORD;
   ppwszAutoConfigUrl: PLPWSTR
): BOOL; stdcall; external Winhttpdll name 'WinHttpDetectAutoProxyConfigUrl';

function WinHttpGetProxyForUrl
(
   hSession: HINTERNET;
   lpcwszUrl: LPCWSTR;
   pAutoProxyOptions: PWinHttpAutoProxyOptions;
   pProxyInfo:  PWinHttpProxyInfo
): BOOL; stdcall; external Winhttpdll name 'WinHttpGetProxyForUrl';

type
  PWinHttpCurrentUserIEProxyConfig = ^TWinHttpCurrentUserIEProxyConfig;
  WINHTTP_CURRENT_USER_IE_PROXY_CONFIG = record
    fAutoDetect: BOOL;
    lpszAutoConfigUrl: LPWSTR;
    lpszProxy: LPWSTR;
    lpszProxyBypass: LPWSTR;
  end;
  TWinHttpCurrentUserIEProxyConfig = WINHTTP_CURRENT_USER_IE_PROXY_CONFIG;

function WinHttpGetIEProxyConfigForCurrentUser
(
   pProxyConfig: PWinHttpCurrentUserIEProxyConfig
): BOOL; stdcall; external Winhttpdll name 'WinHttpGetIEProxyConfigForCurrentUser';


//#if !defined(_WINERROR_)

//
// WinHttp API error returns
//
const
  WINHTTP_ERROR_BASE                    = 12000;

  ERROR_WINHTTP_OUT_OF_HANDLES          = (WINHTTP_ERROR_BASE + 1);
  ERROR_WINHTTP_TIMEOUT                 = (WINHTTP_ERROR_BASE + 2);
  ERROR_WINHTTP_INTERNAL_ERROR          = (WINHTTP_ERROR_BASE + 4);
  ERROR_WINHTTP_INVALID_URL             = (WINHTTP_ERROR_BASE + 5);
  ERROR_WINHTTP_UNRECOGNIZED_SCHEME     = (WINHTTP_ERROR_BASE + 6);
  ERROR_WINHTTP_NAME_NOT_RESOLVED       = (WINHTTP_ERROR_BASE + 7);
  ERROR_WINHTTP_INVALID_OPTION          = (WINHTTP_ERROR_BASE + 9);
  ERROR_WINHTTP_OPTION_NOT_SETTABLE     = (WINHTTP_ERROR_BASE + 11);
  ERROR_WINHTTP_SHUTDOWN                = (WINHTTP_ERROR_BASE + 12);


  ERROR_WINHTTP_LOGIN_FAILURE           = (WINHTTP_ERROR_BASE + 15);
  ERROR_WINHTTP_OPERATION_CANCELLED     = (WINHTTP_ERROR_BASE + 17);
  ERROR_WINHTTP_INCORRECT_HANDLE_TYPE   = (WINHTTP_ERROR_BASE + 18);
  ERROR_WINHTTP_INCORRECT_HANDLE_STATE  = (WINHTTP_ERROR_BASE + 19);
  ERROR_WINHTTP_CANNOT_CONNECT          = (WINHTTP_ERROR_BASE + 29);
  ERROR_WINHTTP_CONNECTION_ERROR        = (WINHTTP_ERROR_BASE + 30);
  ERROR_WINHTTP_RESEND_REQUEST          = (WINHTTP_ERROR_BASE + 32);

  ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED = (WINHTTP_ERROR_BASE + 44);

//
// WinHttpRequest Component errors
//
  ERROR_WINHTTP_CANNOT_CALL_BEFORE_OPEN	= (WINHTTP_ERROR_BASE + 100);
  ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND	= (WINHTTP_ERROR_BASE + 101);
  ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND	= (WINHTTP_ERROR_BASE + 102);
  ERROR_WINHTTP_CANNOT_CALL_AFTER_OPEN  = (WINHTTP_ERROR_BASE + 103);


//
// HTTP API errors
//

  ERROR_WINHTTP_HEADER_NOT_FOUND           = (WINHTTP_ERROR_BASE + 150);
  ERROR_WINHTTP_INVALID_SERVER_RESPONSE    = (WINHTTP_ERROR_BASE + 152);
  ERROR_WINHTTP_INVALID_HEADER             = (WINHTTP_ERROR_BASE + 153);
  ERROR_WINHTTP_INVALID_QUERY_REQUEST      = (WINHTTP_ERROR_BASE + 154);
  ERROR_WINHTTP_HEADER_ALREADY_EXISTS      = (WINHTTP_ERROR_BASE + 155);
  ERROR_WINHTTP_REDIRECT_FAILED            = (WINHTTP_ERROR_BASE + 156);



//
// additional WinHttp API error codes
//

//
// additional WinHttp API error codes
//
  ERROR_WINHTTP_AUTO_PROXY_SERVICE_ERROR  = (WINHTTP_ERROR_BASE + 178);
  ERROR_WINHTTP_BAD_AUTO_PROXY_SCRIPT     = (WINHTTP_ERROR_BASE + 166);
  ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT = (WINHTTP_ERROR_BASE + 167);

  ERROR_WINHTTP_NOT_INITIALIZED         = (WINHTTP_ERROR_BASE + 172);
  ERROR_WINHTTP_SECURE_FAILURE          = (WINHTTP_ERROR_BASE + 175);


//
// Certificate security errors. These are raised only by the WinHttpRequest
// component. The WinHTTP Win32 API will return ERROR_WINHTTP_SECURE_FAILE and
// provide additional information via the WINHTTP_CALLBACK_STATUS_SECURE_FAILURE
// callback notification.
//
  ERROR_WINHTTP_SECURE_CERT_DATE_INVALID  = (WINHTTP_ERROR_BASE + 37);
  ERROR_WINHTTP_SECURE_CERT_CN_INVALID    = (WINHTTP_ERROR_BASE + 38);
  ERROR_WINHTTP_SECURE_INVALID_CA         = (WINHTTP_ERROR_BASE + 45);
  ERROR_WINHTTP_SECURE_CERT_REV_FAILED    = (WINHTTP_ERROR_BASE + 57);
  ERROR_WINHTTP_SECURE_CHANNEL_ERROR      = (WINHTTP_ERROR_BASE + 157);
  ERROR_WINHTTP_SECURE_INVALID_CERT       = (WINHTTP_ERROR_BASE + 169);
  ERROR_WINHTTP_SECURE_CERT_REVOKED       = (WINHTTP_ERROR_BASE + 170);
  ERROR_WINHTTP_SECURE_CERT_WRONG_USAGE   = (WINHTTP_ERROR_BASE + 179);


  ERROR_WINHTTP_AUTODETECTION_FAILED                  = (WINHTTP_ERROR_BASE + 180);
  ERROR_WINHTTP_HEADER_COUNT_EXCEEDED                 = (WINHTTP_ERROR_BASE + 181);
  ERROR_WINHTTP_HEADER_SIZE_OVERFLOW                  = (WINHTTP_ERROR_BASE + 182);
  ERROR_WINHTTP_CHUNKED_ENCODING_HEADER_SIZE_OVERFLOW = (WINHTTP_ERROR_BASE + 183);
  ERROR_WINHTTP_RESPONSE_DRAIN_OVERFLOW               = (WINHTTP_ERROR_BASE + 184);
  ERROR_WINHTTP_CLIENT_CERT_NO_PRIVATE_KEY            = (WINHTTP_ERROR_BASE + 185);
  ERROR_WINHTTP_CLIENT_CERT_NO_ACCESS_PRIVATE_KEY     = (WINHTTP_ERROR_BASE + 186);

  WINHTTP_ERROR_LAST                                  = (WINHTTP_ERROR_BASE + 186);

implementation

end.
winhttp.pas (44,059 bytes)

Jonas Maebe

2016-09-26 16:11

manager   ~0094822

That code is licensed under the LGPLv3 (https://github.com/yryz/winhttp/blob/master/LICENSE ), which is incompatible with the GPLv2. For that reason, it may be a better idea to include a different translation of that header (to the extent that header translations are copyrightable at all, but that's a different matter).

Michal Gawrycki

2016-09-26 16:46

reporter   ~0094823

Ok. This one is generated by h2pas from
https://github.com/kinke/mingw-w64-crt/blob/master/mingw-w64-headers/include/winhttp.h

I left the original license notice, I do not know if I should change it.

Michal Gawrycki

2016-09-26 16:48

reporter  

winhttp.2.pas (26,676 bytes)
unit winhttp;

interface

uses
  windows;

{$ifdef win64}
   {$packrecords 8}
 {$else}
   {$packrecords 4}
 {$endif}


const
  External_library='winhttp.dll'; {Setup as you need}


  {
   * Copyright (C) 2007 Francois Gouget
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License as published by the Free Software Foundation; either
   * version 2.1 of the License, or (at your option) any later version.
   *
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with this library; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  }



type
  PHINTERNET = ^HINTERNET;
  HINTERNET = LPVOID;

  PLPHINTERNET = ^LPHINTERNET;
  LPHINTERNET = PHINTERNET;

const
  INTERNET_DEFAULT_PORT = 0;
  INTERNET_DEFAULT_HTTP_PORT = 80;
  INTERNET_DEFAULT_HTTPS_PORT = 443;

type
  PINTERNET_PORT = ^INTERNET_PORT;
  INTERNET_PORT = WORD;

  PLPINTERNET_PORT = ^LPINTERNET_PORT;
  LPINTERNET_PORT = PINTERNET_PORT;

const
  INTERNET_SCHEME_HTTP = 1;
  INTERNET_SCHEME_HTTPS = 2;

type
  PINTERNET_SCHEME = ^INTERNET_SCHEME;
  INTERNET_SCHEME = longint;
  LPINTERNET_SCHEME = PINTERNET_SCHEME;
  PLPINTERNET_SCHEME = ^LPINTERNET_SCHEME;

const
  ICU_ESCAPE = $80000000;
{ flags for WinHttpOpen  }
  WINHTTP_FLAG_ASYNC = $10000000;
{ flags for WinHttpOpenRequest  }
  WINHTTP_FLAG_ESCAPE_PERCENT = $00000004;
  WINHTTP_FLAG_NULL_CODEPAGE = $00000008;
  WINHTTP_FLAG_ESCAPE_DISABLE = $00000040;
  WINHTTP_FLAG_ESCAPE_DISABLE_QUERY = $00000080;
  WINHTTP_FLAG_BYPASS_PROXY_CACHE = $00000100;
  WINHTTP_FLAG_REFRESH = WINHTTP_FLAG_BYPASS_PROXY_CACHE;
  WINHTTP_FLAG_SECURE = $00800000;
  WINHTTP_ACCESS_TYPE_DEFAULT_PROXY = 0;
  WINHTTP_ACCESS_TYPE_NO_PROXY = 1;
  WINHTTP_ACCESS_TYPE_NAMED_PROXY = 3;
  WINHTTP_NO_PROXY_NAME = nil;
  WINHTTP_NO_PROXY_BYPASS = nil;
  WINHTTP_NO_REFERER = nil;
  WINHTTP_DEFAULT_ACCEPT_TYPES = nil;
  WINHTTP_NO_ADDITIONAL_HEADERS = nil;
  WINHTTP_NO_REQUEST_DATA = nil;
  WINHTTP_HEADER_NAME_BY_INDEX = nil;
  WINHTTP_NO_OUTPUT_BUFFER = nil;
  WINHTTP_NO_HEADER_INDEX = nil;
  WINHTTP_ADDREQ_INDEX_MASK = $0000FFFF;
  WINHTTP_ADDREQ_FLAGS_MASK = $FFFF0000;
  WINHTTP_ADDREQ_FLAG_ADD_IF_NEW = $10000000;
  WINHTTP_ADDREQ_FLAG_ADD = $20000000;
  WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA = $40000000;
  WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON = $01000000;
  WINHTTP_ADDREQ_FLAG_COALESCE = WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA;
  WINHTTP_ADDREQ_FLAG_REPLACE = $80000000;
  WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH = 0;
{ flags for WinHttpSet/QueryOptions  }
  WINHTTP_OPTION_CALLBACK = 1;
  WINHTTP_FIRST_OPTION = WINHTTP_OPTION_CALLBACK;
  WINHTTP_OPTION_RESOLVE_TIMEOUT = 2;
  WINHTTP_OPTION_CONNECT_TIMEOUT = 3;
  WINHTTP_OPTION_CONNECT_RETRIES = 4;
  WINHTTP_OPTION_SEND_TIMEOUT = 5;
  WINHTTP_OPTION_RECEIVE_TIMEOUT = 6;
  WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT = 7;
  WINHTTP_OPTION_HANDLE_TYPE = 9;
  WINHTTP_OPTION_READ_BUFFER_SIZE = 12;
  WINHTTP_OPTION_WRITE_BUFFER_SIZE = 13;
  WINHTTP_OPTION_PARENT_HANDLE = 21;
  WINHTTP_OPTION_EXTENDED_ERROR = 24;
  WINHTTP_OPTION_SECURITY_FLAGS = 31;
  WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT = 32;
  WINHTTP_OPTION_URL = 34;
  WINHTTP_OPTION_SECURITY_KEY_BITNESS = 36;
  WINHTTP_OPTION_PROXY = 38;
  WINHTTP_OPTION_USER_AGENT = 41;
  WINHTTP_OPTION_CONTEXT_VALUE = 45;
  WINHTTP_OPTION_CLIENT_CERT_CONTEXT = 47;
  WINHTTP_OPTION_REQUEST_PRIORITY = 58;
  WINHTTP_OPTION_HTTP_VERSION = 59;
  WINHTTP_OPTION_DISABLE_FEATURE = 63;
  WINHTTP_OPTION_CODEPAGE = 68;
  WINHTTP_OPTION_MAX_CONNS_PER_SERVER = 73;
  WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER = 74;
  WINHTTP_OPTION_AUTOLOGON_POLICY = 77;
  WINHTTP_OPTION_SERVER_CERT_CONTEXT = 78;
  WINHTTP_OPTION_ENABLE_FEATURE = 79;
  WINHTTP_OPTION_WORKER_THREAD_COUNT = 80;
  WINHTTP_OPTION_PASSPORT_COBRANDING_TEXT = 81;
  WINHTTP_OPTION_PASSPORT_COBRANDING_URL = 82;
  WINHTTP_OPTION_CONFIGURE_PASSPORT_AUTH = 83;
  WINHTTP_OPTION_SECURE_PROTOCOLS = 84;
  WINHTTP_OPTION_ENABLETRACING = 85;
  WINHTTP_OPTION_PASSPORT_SIGN_OUT = 86;
  WINHTTP_OPTION_PASSPORT_RETURN_URL = 87;
  WINHTTP_OPTION_REDIRECT_POLICY = 88;
  WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS = 89;
  WINHTTP_OPTION_MAX_HTTP_STATUS_CONTINUE = 90;
  WINHTTP_OPTION_MAX_RESPONSE_HEADER_SIZE = 91;
  WINHTTP_OPTION_MAX_RESPONSE_DRAIN_SIZE = 92;
  WINHTTP_OPTION_CONNECTION_INFO = 93;
  WINHTTP_OPTION_CLIENT_CERT_ISSUER_LIST = 94;
  WINHTTP_OPTION_SPN = 96;
  WINHTTP_OPTION_GLOBAL_PROXY_CREDS = 97;
  WINHTTP_OPTION_GLOBAL_SERVER_CREDS = 98;
  WINHTTP_OPTION_UNLOAD_NOTIFY_EVENT = 99;
  WINHTTP_OPTION_REJECT_USERPWD_IN_URL = 100;
  WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS = 101;
  WINHTTP_LAST_OPTION = WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS;
  WINHTTP_OPTION_USERNAME = $1000;
  WINHTTP_OPTION_PASSWORD = $1001;
  WINHTTP_OPTION_PROXY_USERNAME = $1002;
  WINHTTP_OPTION_PROXY_PASSWORD = $1003;
  WINHTTP_CONNS_PER_SERVER_UNLIMITED = $FFFFFFFF;
  WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM = 0;
  WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW = 1;
  WINHTTP_AUTOLOGON_SECURITY_LEVEL_HIGH = 2;
  WINHTTP_AUTOLOGON_SECURITY_LEVEL_DEFAULT = WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM;
  WINHTTP_OPTION_REDIRECT_POLICY_NEVER = 0;
  WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP = 1;
  WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS = 2;
  WINHTTP_OPTION_REDIRECT_POLICY_LAST = WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS;
  WINHTTP_OPTION_REDIRECT_POLICY_DEFAULT = WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP;
  WINHTTP_DISABLE_PASSPORT_AUTH = $00000000;
  WINHTTP_ENABLE_PASSPORT_AUTH = $10000000;
  WINHTTP_DISABLE_PASSPORT_KEYRING = $20000000;
  WINHTTP_ENABLE_PASSPORT_KEYRING = $40000000;
  WINHTTP_DISABLE_COOKIES = $00000001;
  WINHTTP_DISABLE_REDIRECTS = $00000002;
  WINHTTP_DISABLE_AUTHENTICATION = $00000004;
  WINHTTP_DISABLE_KEEP_ALIVE = $00000008;
  WINHTTP_ENABLE_SSL_REVOCATION = $00000001;
  WINHTTP_ENABLE_SSL_REVERT_IMPERSONATION = $00000002;
  WINHTTP_DISABLE_SPN_SERVER_PORT = $00000000;
  WINHTTP_ENABLE_SPN_SERVER_PORT = $00000001;
  WINHTTP_OPTION_SPN_MASK = WINHTTP_ENABLE_SPN_SERVER_PORT;

  { WinHTTP error codes  }
  WINHTTP_ERROR_BASE = 12000;
  ERROR_WINHTTP_OUT_OF_HANDLES = WINHTTP_ERROR_BASE+1;
  ERROR_WINHTTP_TIMEOUT = WINHTTP_ERROR_BASE+2;
  ERROR_WINHTTP_INTERNAL_ERROR = WINHTTP_ERROR_BASE+4;
  ERROR_WINHTTP_INVALID_URL = WINHTTP_ERROR_BASE+5;
  ERROR_WINHTTP_UNRECOGNIZED_SCHEME = WINHTTP_ERROR_BASE+6;
  ERROR_WINHTTP_NAME_NOT_RESOLVED = WINHTTP_ERROR_BASE+7;
  ERROR_WINHTTP_INVALID_OPTION = WINHTTP_ERROR_BASE+9;
  ERROR_WINHTTP_OPTION_NOT_SETTABLE = WINHTTP_ERROR_BASE+11;
  ERROR_WINHTTP_SHUTDOWN = WINHTTP_ERROR_BASE+12;
  ERROR_WINHTTP_LOGIN_FAILURE = WINHTTP_ERROR_BASE+15;
  ERROR_WINHTTP_OPERATION_CANCELLED = WINHTTP_ERROR_BASE+17;
  ERROR_WINHTTP_INCORRECT_HANDLE_TYPE = WINHTTP_ERROR_BASE+18;
  ERROR_WINHTTP_INCORRECT_HANDLE_STATE = WINHTTP_ERROR_BASE+19;
  ERROR_WINHTTP_CANNOT_CONNECT = WINHTTP_ERROR_BASE+29;
  ERROR_WINHTTP_CONNECTION_ERROR = WINHTTP_ERROR_BASE+30;
  ERROR_WINHTTP_RESEND_REQUEST = WINHTTP_ERROR_BASE+32;
  ERROR_WINHTTP_SECURE_CERT_DATE_INVALID = WINHTTP_ERROR_BASE+37;
  ERROR_WINHTTP_SECURE_CERT_CN_INVALID = WINHTTP_ERROR_BASE+38;
  ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED = WINHTTP_ERROR_BASE+44;
  ERROR_WINHTTP_SECURE_INVALID_CA = WINHTTP_ERROR_BASE+45;
  ERROR_WINHTTP_SECURE_CERT_REV_FAILED = WINHTTP_ERROR_BASE+57;
  ERROR_WINHTTP_CANNOT_CALL_BEFORE_OPEN = WINHTTP_ERROR_BASE+100;
  ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND = WINHTTP_ERROR_BASE+101;
  ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND = WINHTTP_ERROR_BASE+102;
  ERROR_WINHTTP_CANNOT_CALL_AFTER_OPEN = WINHTTP_ERROR_BASE+103;
  ERROR_WINHTTP_HEADER_NOT_FOUND = WINHTTP_ERROR_BASE+150;
  ERROR_WINHTTP_INVALID_SERVER_RESPONSE = WINHTTP_ERROR_BASE+152;
  ERROR_WINHTTP_INVALID_HEADER = WINHTTP_ERROR_BASE+153;
  ERROR_WINHTTP_INVALID_QUERY_REQUEST = WINHTTP_ERROR_BASE+154;
  ERROR_WINHTTP_HEADER_ALREADY_EXISTS = WINHTTP_ERROR_BASE+155;
  ERROR_WINHTTP_REDIRECT_FAILED = WINHTTP_ERROR_BASE+156;
  ERROR_WINHTTP_SECURE_CHANNEL_ERROR = WINHTTP_ERROR_BASE+157;
  ERROR_WINHTTP_BAD_AUTO_PROXY_SCRIPT = WINHTTP_ERROR_BASE+166;
  ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT = WINHTTP_ERROR_BASE+167;
  ERROR_WINHTTP_SECURE_INVALID_CERT = WINHTTP_ERROR_BASE+169;
  ERROR_WINHTTP_SECURE_CERT_REVOKED = WINHTTP_ERROR_BASE+170;
  ERROR_WINHTTP_NOT_INITIALIZED = WINHTTP_ERROR_BASE+172;
  ERROR_WINHTTP_SECURE_FAILURE = WINHTTP_ERROR_BASE+175;
  ERROR_WINHTTP_AUTO_PROXY_SERVICE_ERROR = WINHTTP_ERROR_BASE+178;
  ERROR_WINHTTP_SECURE_CERT_WRONG_USAGE = WINHTTP_ERROR_BASE+179;
  ERROR_WINHTTP_AUTODETECTION_FAILED = WINHTTP_ERROR_BASE+180;
  ERROR_WINHTTP_HEADER_COUNT_EXCEEDED = WINHTTP_ERROR_BASE+181;
  ERROR_WINHTTP_HEADER_SIZE_OVERFLOW = WINHTTP_ERROR_BASE+182;
  ERROR_WINHTTP_CHUNKED_ENCODING_HEADER_SIZE_OVERFLOW = WINHTTP_ERROR_BASE+183;
  ERROR_WINHTTP_RESPONSE_DRAIN_OVERFLOW = WINHTTP_ERROR_BASE+184;
  ERROR_WINHTTP_CLIENT_CERT_NO_PRIVATE_KEY = WINHTTP_ERROR_BASE+185;
  ERROR_WINHTTP_CLIENT_CERT_NO_ACCESS_PRIVATE_KEY = WINHTTP_ERROR_BASE+186;
  WINHTTP_ERROR_LAST = WINHTTP_ERROR_BASE+186;
{ WinHttp status codes  }
  HTTP_STATUS_CONTINUE = 100;
  HTTP_STATUS_SWITCH_PROTOCOLS = 101;
  HTTP_STATUS_OK = 200;
  HTTP_STATUS_CREATED = 201;
  HTTP_STATUS_ACCEPTED = 202;
  HTTP_STATUS_PARTIAL = 203;
  HTTP_STATUS_NO_CONTENT = 204;
  HTTP_STATUS_RESET_CONTENT = 205;
  HTTP_STATUS_PARTIAL_CONTENT = 206;
  HTTP_STATUS_WEBDAV_MULTI_STATUS = 207;
  HTTP_STATUS_AMBIGUOUS = 300;
  HTTP_STATUS_MOVED = 301;
  HTTP_STATUS_REDIRECT = 302;
  HTTP_STATUS_REDIRECT_METHOD = 303;
  HTTP_STATUS_NOT_MODIFIED = 304;
  HTTP_STATUS_USE_PROXY = 305;
  HTTP_STATUS_REDIRECT_KEEP_VERB = 307;
  HTTP_STATUS_BAD_REQUEST = 400;
  HTTP_STATUS_DENIED = 401;
  HTTP_STATUS_PAYMENT_REQ = 402;
  HTTP_STATUS_FORBIDDEN = 403;
  HTTP_STATUS_NOT_FOUND = 404;
  HTTP_STATUS_BAD_METHOD = 405;
  HTTP_STATUS_NONE_ACCEPTABLE = 406;
  HTTP_STATUS_PROXY_AUTH_REQ = 407;
  HTTP_STATUS_REQUEST_TIMEOUT = 408;
  HTTP_STATUS_CONFLICT = 409;
  HTTP_STATUS_GONE = 410;
  HTTP_STATUS_LENGTH_REQUIRED = 411;
  HTTP_STATUS_PRECOND_FAILED = 412;
  HTTP_STATUS_REQUEST_TOO_LARGE = 413;
  HTTP_STATUS_URI_TOO_LONG = 414;
  HTTP_STATUS_UNSUPPORTED_MEDIA = 415;
  HTTP_STATUS_RETRY_WITH = 449;
  HTTP_STATUS_SERVER_ERROR = 500;
  HTTP_STATUS_NOT_SUPPORTED = 501;
  HTTP_STATUS_BAD_GATEWAY = 502;
  HTTP_STATUS_SERVICE_UNAVAIL = 503;
  HTTP_STATUS_GATEWAY_TIMEOUT = 504;
  HTTP_STATUS_VERSION_NOT_SUP = 505;
  HTTP_STATUS_FIRST = HTTP_STATUS_CONTINUE;
  HTTP_STATUS_LAST = HTTP_STATUS_VERSION_NOT_SUP;
  SECURITY_FLAG_IGNORE_UNKNOWN_CA = $00000100;
  SECURITY_FLAG_IGNORE_CERT_DATE_INVALID = $00002000;
  SECURITY_FLAG_IGNORE_CERT_CN_INVALID = $00001000;
  SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE = $00000200;
  SECURITY_FLAG_SECURE = $00000001;
  SECURITY_FLAG_STRENGTH_WEAK = $10000000;
  SECURITY_FLAG_STRENGTH_MEDIUM = $40000000;
  SECURITY_FLAG_STRENGTH_STRONG = $20000000;
  ICU_NO_ENCODE = $20000000;
  ICU_DECODE = $10000000;
  ICU_NO_META = $08000000;
  ICU_ENCODE_SPACES_ONLY = $04000000;
  ICU_BROWSER_MODE = $02000000;
  ICU_ENCODE_PERCENT = $00001000;
{ Query flags  }
  WINHTTP_QUERY_MIME_VERSION = 0;
  WINHTTP_QUERY_CONTENT_TYPE = 1;
  WINHTTP_QUERY_CONTENT_TRANSFER_ENCODING = 2;
  WINHTTP_QUERY_CONTENT_ID = 3;
  WINHTTP_QUERY_CONTENT_DESCRIPTION = 4;
  WINHTTP_QUERY_CONTENT_LENGTH = 5;
  WINHTTP_QUERY_CONTENT_LANGUAGE = 6;
  WINHTTP_QUERY_ALLOW = 7;
  WINHTTP_QUERY_PUBLIC = 8;
  WINHTTP_QUERY_DATE = 9;
  WINHTTP_QUERY_EXPIRES = 10;
  WINHTTP_QUERY_LAST_MODIFIED = 11;
  WINHTTP_QUERY_MESSAGE_ID = 12;
  WINHTTP_QUERY_URI = 13;
  WINHTTP_QUERY_DERIVED_FROM = 14;
  WINHTTP_QUERY_COST = 15;
  WINHTTP_QUERY_LINK = 16;
  WINHTTP_QUERY_PRAGMA = 17;
  WINHTTP_QUERY_VERSION = 18;
  WINHTTP_QUERY_STATUS_CODE = 19;
  WINHTTP_QUERY_STATUS_TEXT = 20;
  WINHTTP_QUERY_RAW_HEADERS = 21;
  WINHTTP_QUERY_RAW_HEADERS_CRLF = 22;
  WINHTTP_QUERY_CONNECTION = 23;
  WINHTTP_QUERY_ACCEPT = 24;
  WINHTTP_QUERY_ACCEPT_CHARSET = 25;
  WINHTTP_QUERY_ACCEPT_ENCODING = 26;
  WINHTTP_QUERY_ACCEPT_LANGUAGE = 27;
  WINHTTP_QUERY_AUTHORIZATION = 28;
  WINHTTP_QUERY_CONTENT_ENCODING = 29;
  WINHTTP_QUERY_FORWARDED = 30;
  WINHTTP_QUERY_FROM = 31;
  WINHTTP_QUERY_IF_MODIFIED_SINCE = 32;
  WINHTTP_QUERY_LOCATION = 33;
  WINHTTP_QUERY_ORIG_URI = 34;
  WINHTTP_QUERY_REFERER = 35;
  WINHTTP_QUERY_RETRY_AFTER = 36;
  WINHTTP_QUERY_SERVER = 37;
  WINHTTP_QUERY_TITLE = 38;
  WINHTTP_QUERY_USER_AGENT = 39;
  WINHTTP_QUERY_WWW_AUTHENTICATE = 40;
  WINHTTP_QUERY_PROXY_AUTHENTICATE = 41;
  WINHTTP_QUERY_ACCEPT_RANGES = 42;
  WINHTTP_QUERY_SET_COOKIE = 43;
  WINHTTP_QUERY_COOKIE = 44;
  WINHTTP_QUERY_REQUEST_METHOD = 45;
  WINHTTP_QUERY_REFRESH = 46;
  WINHTTP_QUERY_CONTENT_DISPOSITION = 47;
  WINHTTP_QUERY_AGE = 48;
  WINHTTP_QUERY_CACHE_CONTROL = 49;
  WINHTTP_QUERY_CONTENT_BASE = 50;
  WINHTTP_QUERY_CONTENT_LOCATION = 51;
  WINHTTP_QUERY_CONTENT_MD5 = 52;
  WINHTTP_QUERY_CONTENT_RANGE = 53;
  WINHTTP_QUERY_ETAG = 54;
  WINHTTP_QUERY_HOST = 55;
  WINHTTP_QUERY_IF_MATCH = 56;
  WINHTTP_QUERY_IF_NONE_MATCH = 57;
  WINHTTP_QUERY_IF_RANGE = 58;
  WINHTTP_QUERY_IF_UNMODIFIED_SINCE = 59;
  WINHTTP_QUERY_MAX_FORWARDS = 60;
  WINHTTP_QUERY_PROXY_AUTHORIZATION = 61;
  WINHTTP_QUERY_RANGE = 62;
  WINHTTP_QUERY_TRANSFER_ENCODING = 63;
  WINHTTP_QUERY_UPGRADE = 64;
  WINHTTP_QUERY_VARY = 65;
  WINHTTP_QUERY_VIA = 66;
  WINHTTP_QUERY_WARNING = 67;
  WINHTTP_QUERY_EXPECT = 68;
  WINHTTP_QUERY_PROXY_CONNECTION = 69;
  WINHTTP_QUERY_UNLESS_MODIFIED_SINCE = 70;
  WINHTTP_QUERY_PROXY_SUPPORT = 75;
  WINHTTP_QUERY_AUTHENTICATION_INFO = 76;
  WINHTTP_QUERY_PASSPORT_URLS = 77;
  WINHTTP_QUERY_PASSPORT_CONFIG = 78;
  WINHTTP_QUERY_MAX = 78;
  WINHTTP_QUERY_CUSTOM = 65535;
  WINHTTP_QUERY_FLAG_REQUEST_HEADERS = $80000000;
  WINHTTP_QUERY_FLAG_SYSTEMTIME = $40000000;
  WINHTTP_QUERY_FLAG_NUMBER = $20000000;
{ Callback options  }
  WINHTTP_CALLBACK_STATUS_RESOLVING_NAME = $00000001;
  WINHTTP_CALLBACK_STATUS_NAME_RESOLVED = $00000002;
  WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER = $00000004;
  WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER = $00000008;
  WINHTTP_CALLBACK_STATUS_SENDING_REQUEST = $00000010;
  WINHTTP_CALLBACK_STATUS_REQUEST_SENT = $00000020;
  WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE = $00000040;
  WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED = $00000080;
  WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION = $00000100;
  WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED = $00000200;
  WINHTTP_CALLBACK_STATUS_HANDLE_CREATED = $00000400;
  WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING = $00000800;
  WINHTTP_CALLBACK_STATUS_DETECTING_PROXY = $00001000;
  WINHTTP_CALLBACK_STATUS_REDIRECT = $00004000;
  WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE = $00008000;
  WINHTTP_CALLBACK_STATUS_SECURE_FAILURE = $00010000;
  WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE = $00020000;
  WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE = $00040000;
  WINHTTP_CALLBACK_STATUS_READ_COMPLETE = $00080000;
  WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE = $00100000;
  WINHTTP_CALLBACK_STATUS_REQUEST_ERROR = $00200000;
  WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE = $00400000;
  WINHTTP_CALLBACK_FLAG_RESOLVE_NAME = WINHTTP_CALLBACK_STATUS_RESOLVING_NAME or WINHTTP_CALLBACK_STATUS_NAME_RESOLVED;
  WINHTTP_CALLBACK_FLAG_CONNECT_TO_SERVER = WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER or WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER;
  WINHTTP_CALLBACK_FLAG_SEND_REQUEST = WINHTTP_CALLBACK_STATUS_SENDING_REQUEST or WINHTTP_CALLBACK_STATUS_REQUEST_SENT;
  WINHTTP_CALLBACK_FLAG_RECEIVE_RESPONSE = WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE or WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED;
  WINHTTP_CALLBACK_FLAG_CLOSE_CONNECTION = WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION or WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED;
  WINHTTP_CALLBACK_FLAG_HANDLES = WINHTTP_CALLBACK_STATUS_HANDLE_CREATED or WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING;
  WINHTTP_CALLBACK_FLAG_DETECTING_PROXY = WINHTTP_CALLBACK_STATUS_DETECTING_PROXY;
  WINHTTP_CALLBACK_FLAG_REDIRECT = WINHTTP_CALLBACK_STATUS_REDIRECT;
  WINHTTP_CALLBACK_FLAG_INTERMEDIATE_RESPONSE = WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE;
  WINHTTP_CALLBACK_FLAG_SECURE_FAILURE = WINHTTP_CALLBACK_STATUS_SECURE_FAILURE;
  WINHTTP_CALLBACK_FLAG_SENDREQUEST_COMPLETE = WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE;
  WINHTTP_CALLBACK_FLAG_HEADERS_AVAILABLE = WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE;
  WINHTTP_CALLBACK_FLAG_DATA_AVAILABLE = WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE;
  WINHTTP_CALLBACK_FLAG_READ_COMPLETE = WINHTTP_CALLBACK_STATUS_READ_COMPLETE;
  WINHTTP_CALLBACK_FLAG_WRITE_COMPLETE = WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE;
  WINHTTP_CALLBACK_FLAG_REQUEST_ERROR = WINHTTP_CALLBACK_STATUS_REQUEST_ERROR;
  WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS = ((((WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE or WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE) or WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE) or WINHTTP_CALLBACK_STATUS_READ_COMPLETE) or WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE) or WINHTTP_CALLBACK_STATUS_REQUEST_ERROR;
  WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS = $ffffffff;


const
  API_RECEIVE_RESPONSE = 1;
  API_QUERY_DATA_AVAILABLE = 2;
  API_READ_DATA = 3;
  API_WRITE_DATA = 4;
  API_SEND_REQUEST = 5;
  WINHTTP_HANDLE_TYPE_SESSION = 1;
  WINHTTP_HANDLE_TYPE_CONNECT = 2;
  WINHTTP_HANDLE_TYPE_REQUEST = 3;
  WINHTTP_CALLBACK_STATUS_FLAG_CERT_REV_FAILED = $00000001;
  WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CERT = $00000002;
  WINHTTP_CALLBACK_STATUS_FLAG_CERT_REVOKED = $00000004;
  WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CA = $00000008;
  WINHTTP_CALLBACK_STATUS_FLAG_CERT_CN_INVALID = $00000010;
  WINHTTP_CALLBACK_STATUS_FLAG_CERT_DATE_INVALID = $00000020;
  WINHTTP_CALLBACK_STATUS_FLAG_CERT_WRONG_USAGE = $00000040;
  WINHTTP_CALLBACK_STATUS_FLAG_SECURITY_CHANNEL_ERROR = $80000000;
  WINHTTP_FLAG_SECURE_PROTOCOL_SSL2 = $00000008;
  WINHTTP_FLAG_SECURE_PROTOCOL_SSL3 = $00000020;
  WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 = $00000080;
  WINHTTP_FLAG_SECURE_PROTOCOL_ALL = (WINHTTP_FLAG_SECURE_PROTOCOL_SSL2 or WINHTTP_FLAG_SECURE_PROTOCOL_SSL3) or WINHTTP_FLAG_SECURE_PROTOCOL_TLS1;
  WINHTTP_AUTH_SCHEME_BASIC = $00000001;
  WINHTTP_AUTH_SCHEME_NTLM = $00000002;
  WINHTTP_AUTH_SCHEME_PASSPORT = $00000004;
  WINHTTP_AUTH_SCHEME_DIGEST = $00000008;
  WINHTTP_AUTH_SCHEME_NEGOTIATE = $00000010;
  WINHTTP_AUTH_TARGET_SERVER = $00000000;
  WINHTTP_AUTH_TARGET_PROXY = $00000001;
  WINHTTP_TIME_FORMAT_BUFSIZE = 62;

type
  PURL_COMPONENTS = ^URL_COMPONENTS;
  URL_COMPONENTS = record
      dwStructSize : DWORD;
      lpszScheme : LPWSTR;
      dwSchemeLength : DWORD;
      nScheme : INTERNET_SCHEME;
      lpszHostName : LPWSTR;
      dwHostNameLength : DWORD;
      nPort : INTERNET_PORT;
      lpszUserName : LPWSTR;
      dwUserNameLength : DWORD;
      lpszPassword : LPWSTR;
      dwPasswordLength : DWORD;
      lpszUrlPath : LPWSTR;
      dwUrlPathLength : DWORD;
      lpszExtraInfo : LPWSTR;
      dwExtraInfoLength : DWORD;
    end;
  LPURL_COMPONENTS = PURL_COMPONENTS;
  PLPURL_COMPONENTS = ^LPURL_COMPONENTS;

  PURL_COMPONENTSW = ^URL_COMPONENTSW;
  URL_COMPONENTSW = URL_COMPONENTS;

  PLPURL_COMPONENTSW = ^LPURL_COMPONENTSW;
  LPURL_COMPONENTSW = LPURL_COMPONENTS;

  PWINHTTP_ASYNC_RESULT = ^WINHTTP_ASYNC_RESULT;
  WINHTTP_ASYNC_RESULT = record
      dwResult : DWORD_PTR;
      dwError : DWORD;
    end;
  LPWINHTTP_ASYNC_RESULT = PWINHTTP_ASYNC_RESULT;
  PLPWINHTTP_ASYNC_RESULT = ^LPWINHTTP_ASYNC_RESULT;

  PWINHTTP_CERTIFICATE_INFO = ^WINHTTP_CERTIFICATE_INFO;
  WINHTTP_CERTIFICATE_INFO = record
      ftExpiry : FILETIME;
      ftStart : FILETIME;
      lpszSubjectInfo : LPWSTR;
      lpszIssuerInfo : LPWSTR;
      lpszProtocolName : LPWSTR;
      lpszSignatureAlgName : LPWSTR;
      lpszEncryptionAlgName : LPWSTR;
      dwKeySize : DWORD;
    end;

  PWINHTTP_PROXY_INFO = ^WINHTTP_PROXY_INFO;
  WINHTTP_PROXY_INFO = record
      dwAccessType : DWORD;
      lpszProxy : LPCWSTR;
      lpszProxyBypass : LPCWSTR;
    end;
  LPWINHTTP_PROXY_INFO = PWINHTTP_PROXY_INFO;
  PLPWINHTTP_PROXY_INFO = ^LPWINHTTP_PROXY_INFO;

  PWINHTTP_PROXY_INFOW = ^WINHTTP_PROXY_INFOW;
  WINHTTP_PROXY_INFOW = WINHTTP_PROXY_INFO;

  PLPWINHTTP_PROXY_INFOW = ^LPWINHTTP_PROXY_INFOW;
  LPWINHTTP_PROXY_INFOW = LPWINHTTP_PROXY_INFO;

  PWINHTTP_CURRENT_USER_IE_PROXY_CONFIG = ^WINHTTP_CURRENT_USER_IE_PROXY_CONFIG;
  WINHTTP_CURRENT_USER_IE_PROXY_CONFIG = record
      fAutoDetect : WINBOOL;
      lpszAutoConfigUrl : LPWSTR;
      lpszProxy : LPWSTR;
      lpszProxyBypass : LPWSTR;
    end;

  WINHTTP_STATUS_CALLBACK = procedure (_para1:HINTERNET; _para2:DWORD_PTR; _para3:DWORD; _para4:LPVOID; _para5:DWORD);

  PWINHTTP_AUTOPROXY_OPTIONS = ^WINHTTP_AUTOPROXY_OPTIONS;
  WINHTTP_AUTOPROXY_OPTIONS = record
      dwFlags : DWORD;
      dwAutoDetectFlags : DWORD;
      lpszAutoConfigUrl : LPCWSTR;
      lpvReserved : LPVOID;
      dwReserved : DWORD;
      fAutoLogonIfChallenged : WINBOOL;
    end;

  PHTTP_VERSION_INFO = ^HTTP_VERSION_INFO;
  HTTP_VERSION_INFO = record
      dwMajorVersion : DWORD;
      dwMinorVersion : DWORD;
    end;
  LPHTTP_VERSION_INFO = PHTTP_VERSION_INFO;
  PLPHTTP_VERSION_INFO = ^LPHTTP_VERSION_INFO;

function WINHTTP_INVALID_STATUS_CALLBACK : WINHTTP_STATUS_CALLBACK;
function WinHttpAddRequestHeaders(_para1:HINTERNET; _para2:LPCWSTR; _para3:DWORD; _para4:DWORD):WINBOOL;external External_library name 'WinHttpAddRequestHeaders';
function WinHttpDetectAutoProxyConfigUrl(_para1:DWORD; _para2:PLPWSTR):WINBOOL;external External_library name 'WinHttpDetectAutoProxyConfigUrl';
function WinHttpCheckPlatform:WINBOOL;external External_library name 'WinHttpCheckPlatform';
function WinHttpCloseHandle(_para1:HINTERNET):WINBOOL;external External_library name 'WinHttpCloseHandle';
function WinHttpConnect(_para1:HINTERNET; _para2:LPCWSTR; _para3:INTERNET_PORT; _para4:DWORD):HINTERNET;external External_library name 'WinHttpConnect';
function WinHttpCrackUrl(_para1:LPCWSTR; _para2:DWORD; _para3:DWORD; _para4:LPURL_COMPONENTS):WINBOOL;external External_library name 'WinHttpCrackUrl';
function WinHttpCreateUrl(_para1:LPURL_COMPONENTS; _para2:DWORD; _para3:LPWSTR; _para4:LPDWORD):WINBOOL;external External_library name 'WinHttpCreateUrl';
function WinHttpGetDefaultProxyConfiguration(_para1:PWINHTTP_PROXY_INFO):WINBOOL;external External_library name 'WinHttpGetDefaultProxyConfiguration';
function WinHttpGetIEProxyConfigForCurrentUser(_para1:PWINHTTP_CURRENT_USER_IE_PROXY_CONFIG):WINBOOL;external External_library name 'WinHttpGetIEProxyConfigForCurrentUser';
function WinHttpGetProxyForUrl(_para1:HINTERNET; _para2:LPCWSTR; _para3:PWINHTTP_AUTOPROXY_OPTIONS; _para4:PWINHTTP_PROXY_INFO):WINBOOL;external External_library name 'WinHttpGetProxyForUrl';
function WinHttpOpen(_para1:LPCWSTR; _para2:DWORD; _para3:LPCWSTR; _para4:LPCWSTR; _para5:DWORD):HINTERNET;external External_library name 'WinHttpOpen';
function WinHttpOpenRequest(_para1:HINTERNET; _para2:LPCWSTR; _para3:LPCWSTR; _para4:LPCWSTR; _para5:LPCWSTR;
  _para6:LPCWSTR; _para7:DWORD):HINTERNET;external External_library name 'WinHttpOpenRequest';
function WinHttpQueryAuthParams(_para1:HINTERNET; _para2:DWORD; _para3:LPVOID):WINBOOL;external External_library name 'WinHttpQueryAuthParams';
function WinHttpQueryAuthSchemes(_para1:HINTERNET; _para2:LPDWORD; _para3:LPDWORD; _para4:LPDWORD):WINBOOL;external External_library name 'WinHttpQueryAuthSchemes';
function WinHttpQueryDataAvailable(_para1:HINTERNET; _para2:LPDWORD):WINBOOL;external External_library name 'WinHttpQueryDataAvailable';
function WinHttpQueryHeaders(_para1:HINTERNET; _para2:DWORD; _para3:LPCWSTR; _para4:LPVOID; _para5:LPDWORD;
  _para6:LPDWORD):WINBOOL;external External_library name 'WinHttpQueryHeaders';
function WinHttpQueryOption(_para1:HINTERNET; _para2:DWORD; _para3:LPVOID; _para4:LPDWORD):WINBOOL;external External_library name 'WinHttpQueryOption';
function WinHttpReadData(_para1:HINTERNET; _para2:LPVOID; _para3:DWORD; _para4:LPDWORD):WINBOOL;external External_library name 'WinHttpReadData';
function WinHttpReceiveResponse(_para1:HINTERNET; _para2:LPVOID):WINBOOL;external External_library name 'WinHttpReceiveResponse';
function WinHttpSendRequest(_para1:HINTERNET; _para2:LPCWSTR; _para3:DWORD; _para4:LPVOID; _para5:DWORD;
  _para6:DWORD; _para7:DWORD_PTR):WINBOOL;external External_library name 'WinHttpSendRequest';
function WinHttpSetDefaultProxyConfiguration(_para1:PWINHTTP_PROXY_INFO):WINBOOL;external External_library name 'WinHttpSetDefaultProxyConfiguration';
function WinHttpSetCredentials(_para1:HINTERNET; _para2:DWORD; _para3:DWORD; _para4:LPCWSTR; _para5:LPCWSTR;
   _para6:LPVOID):WINBOOL;external External_library name 'WinHttpSetCredentials';
function WinHttpSetOption(_para1:HINTERNET; _para2:DWORD; _para3:LPVOID; _para4:DWORD):WINBOOL;external External_library name 'WinHttpSetOption';
function WinHttpSetStatusCallback(_para1:HINTERNET; _para2:WINHTTP_STATUS_CALLBACK; _para3:DWORD; _para4:DWORD_PTR):WINHTTP_STATUS_CALLBACK;external External_library name 'WinHttpSetStatusCallback';
function WinHttpSetTimeouts(_para1:HINTERNET; _para2:longint; _para3:longint; _para4:longint; _para5:longint):WINBOOL;external External_library name 'WinHttpSetTimeouts';
function WinHttpTimeFromSystemTime(_para1:PSYSTEMTIME; _para2:LPWSTR):WINBOOL;external External_library name 'WinHttpTimeFromSystemTime';
function WinHttpTimeToSystemTime(_para1:LPCWSTR; _para2:PSYSTEMTIME):WINBOOL;external External_library name 'WinHttpTimeToSystemTime';
function WinHttpWriteData(_para1:HINTERNET; _para2:LPCVOID; _para3:DWORD; _para4:LPDWORD):WINBOOL;external External_library name 'WinHttpWriteData';

implementation

function WINHTTP_INVALID_STATUS_CALLBACK : WINHTTP_STATUS_CALLBACK;
begin
  WINHTTP_INVALID_STATUS_CALLBACK:=WINHTTP_STATUS_CALLBACK(-(1));
end;

end.
winhttp.2.pas (26,676 bytes)

Michal Gawrycki

2017-07-07 20:03

reporter  

winhttp.3.pas (28,257 bytes)
{
    This file is part of the Free Pascal run time library.
    Copyright (c) 2017 by Free Pascal development team.

    See the file COPYING.FPC, included in this distribution,
    for details about the copyright.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    Original copyright statement follows.

 * Copyright (C) 2007 Francois Gouget
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
}

unit winhttp;

interface

uses
  Windows;

 {$ifdef win64}
   {$packrecords 8}
 {$else}
   {$packrecords 4}
 {$endif}

const
  LIB_WINHTTPDLL = 'winhttp.dll';

type
  PHINTERNET = ^HINTERNET;
  HINTERNET = LPVOID;

  PLPHINTERNET = ^LPHINTERNET;
  LPHINTERNET = PHINTERNET;

const
  INTERNET_DEFAULT_PORT = 0;
  INTERNET_DEFAULT_HTTP_PORT = 80;
  INTERNET_DEFAULT_HTTPS_PORT = 443;

type
  PINTERNET_PORT = ^INTERNET_PORT;
  INTERNET_PORT = word;

  PLPINTERNET_PORT = ^LPINTERNET_PORT;
  LPINTERNET_PORT = PINTERNET_PORT;

const
  INTERNET_SCHEME_HTTP = 1;
  INTERNET_SCHEME_HTTPS = 2;

type
  PINTERNET_SCHEME = ^INTERNET_SCHEME;
  INTERNET_SCHEME = longint;
  LPINTERNET_SCHEME = PINTERNET_SCHEME;
  PLPINTERNET_SCHEME = ^LPINTERNET_SCHEME;

const
  ICU_ESCAPE = $80000000;
  { flags for WinHttpOpen  }
  WINHTTP_FLAG_ASYNC = $10000000;
  { flags for WinHttpOpenRequest  }
  WINHTTP_FLAG_ESCAPE_PERCENT = $00000004;
  WINHTTP_FLAG_NULL_CODEPAGE = $00000008;
  WINHTTP_FLAG_ESCAPE_DISABLE = $00000040;
  WINHTTP_FLAG_ESCAPE_DISABLE_QUERY = $00000080;
  WINHTTP_FLAG_BYPASS_PROXY_CACHE = $00000100;
  WINHTTP_FLAG_REFRESH = WINHTTP_FLAG_BYPASS_PROXY_CACHE;
  WINHTTP_FLAG_SECURE = $00800000;
  WINHTTP_ACCESS_TYPE_DEFAULT_PROXY = 0;
  WINHTTP_ACCESS_TYPE_NO_PROXY = 1;
  WINHTTP_ACCESS_TYPE_NAMED_PROXY = 3;
  WINHTTP_NO_PROXY_NAME = nil;
  WINHTTP_NO_PROXY_BYPASS = nil;
  WINHTTP_NO_REFERER = nil;
  WINHTTP_DEFAULT_ACCEPT_TYPES = nil;
  WINHTTP_NO_ADDITIONAL_HEADERS = nil;
  WINHTTP_NO_REQUEST_DATA = nil;
  WINHTTP_HEADER_NAME_BY_INDEX = nil;
  WINHTTP_NO_OUTPUT_BUFFER = nil;
  WINHTTP_NO_HEADER_INDEX = nil;
  WINHTTP_ADDREQ_INDEX_MASK = $0000FFFF;
  WINHTTP_ADDREQ_FLAGS_MASK = $FFFF0000;
  WINHTTP_ADDREQ_FLAG_ADD_IF_NEW = $10000000;
  WINHTTP_ADDREQ_FLAG_ADD = $20000000;
  WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA = $40000000;
  WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON = $01000000;
  WINHTTP_ADDREQ_FLAG_COALESCE = WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA;
  WINHTTP_ADDREQ_FLAG_REPLACE = $80000000;
  WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH = 0;
  { flags for WinHttpSet/QueryOptions  }
  WINHTTP_OPTION_CALLBACK = 1;
  WINHTTP_FIRST_OPTION = WINHTTP_OPTION_CALLBACK;
  WINHTTP_OPTION_RESOLVE_TIMEOUT = 2;
  WINHTTP_OPTION_CONNECT_TIMEOUT = 3;
  WINHTTP_OPTION_CONNECT_RETRIES = 4;
  WINHTTP_OPTION_SEND_TIMEOUT = 5;
  WINHTTP_OPTION_RECEIVE_TIMEOUT = 6;
  WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT = 7;
  WINHTTP_OPTION_HANDLE_TYPE = 9;
  WINHTTP_OPTION_READ_BUFFER_SIZE = 12;
  WINHTTP_OPTION_WRITE_BUFFER_SIZE = 13;
  WINHTTP_OPTION_PARENT_HANDLE = 21;
  WINHTTP_OPTION_EXTENDED_ERROR = 24;
  WINHTTP_OPTION_SECURITY_FLAGS = 31;
  WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT = 32;
  WINHTTP_OPTION_URL = 34;
  WINHTTP_OPTION_SECURITY_KEY_BITNESS = 36;
  WINHTTP_OPTION_PROXY = 38;
  WINHTTP_OPTION_USER_AGENT = 41;
  WINHTTP_OPTION_CONTEXT_VALUE = 45;
  WINHTTP_OPTION_CLIENT_CERT_CONTEXT = 47;
  WINHTTP_OPTION_REQUEST_PRIORITY = 58;
  WINHTTP_OPTION_HTTP_VERSION = 59;
  WINHTTP_OPTION_DISABLE_FEATURE = 63;
  WINHTTP_OPTION_CODEPAGE = 68;
  WINHTTP_OPTION_MAX_CONNS_PER_SERVER = 73;
  WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER = 74;
  WINHTTP_OPTION_AUTOLOGON_POLICY = 77;
  WINHTTP_OPTION_SERVER_CERT_CONTEXT = 78;
  WINHTTP_OPTION_ENABLE_FEATURE = 79;
  WINHTTP_OPTION_WORKER_THREAD_COUNT = 80;
  WINHTTP_OPTION_PASSPORT_COBRANDING_TEXT = 81;
  WINHTTP_OPTION_PASSPORT_COBRANDING_URL = 82;
  WINHTTP_OPTION_CONFIGURE_PASSPORT_AUTH = 83;
  WINHTTP_OPTION_SECURE_PROTOCOLS = 84;
  WINHTTP_OPTION_ENABLETRACING = 85;
  WINHTTP_OPTION_PASSPORT_SIGN_OUT = 86;
  WINHTTP_OPTION_PASSPORT_RETURN_URL = 87;
  WINHTTP_OPTION_REDIRECT_POLICY = 88;
  WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS = 89;
  WINHTTP_OPTION_MAX_HTTP_STATUS_CONTINUE = 90;
  WINHTTP_OPTION_MAX_RESPONSE_HEADER_SIZE = 91;
  WINHTTP_OPTION_MAX_RESPONSE_DRAIN_SIZE = 92;
  WINHTTP_OPTION_CONNECTION_INFO = 93;
  WINHTTP_OPTION_CLIENT_CERT_ISSUER_LIST = 94;
  WINHTTP_OPTION_SPN = 96;
  WINHTTP_OPTION_GLOBAL_PROXY_CREDS = 97;
  WINHTTP_OPTION_GLOBAL_SERVER_CREDS = 98;
  WINHTTP_OPTION_UNLOAD_NOTIFY_EVENT = 99;
  WINHTTP_OPTION_REJECT_USERPWD_IN_URL = 100;
  WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS = 101;
  WINHTTP_LAST_OPTION = WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS;
  WINHTTP_OPTION_USERNAME = $1000;
  WINHTTP_OPTION_PASSWORD = $1001;
  WINHTTP_OPTION_PROXY_USERNAME = $1002;
  WINHTTP_OPTION_PROXY_PASSWORD = $1003;
  WINHTTP_CONNS_PER_SERVER_UNLIMITED = $FFFFFFFF;
  WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM = 0;
  WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW = 1;
  WINHTTP_AUTOLOGON_SECURITY_LEVEL_HIGH = 2;
  WINHTTP_AUTOLOGON_SECURITY_LEVEL_DEFAULT = WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM;
  WINHTTP_OPTION_REDIRECT_POLICY_NEVER = 0;
  WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP = 1;
  WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS = 2;
  WINHTTP_OPTION_REDIRECT_POLICY_LAST = WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS;
  WINHTTP_OPTION_REDIRECT_POLICY_DEFAULT =
    WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP;
  WINHTTP_DISABLE_PASSPORT_AUTH = $00000000;
  WINHTTP_ENABLE_PASSPORT_AUTH = $10000000;
  WINHTTP_DISABLE_PASSPORT_KEYRING = $20000000;
  WINHTTP_ENABLE_PASSPORT_KEYRING = $40000000;
  WINHTTP_DISABLE_COOKIES = $00000001;
  WINHTTP_DISABLE_REDIRECTS = $00000002;
  WINHTTP_DISABLE_AUTHENTICATION = $00000004;
  WINHTTP_DISABLE_KEEP_ALIVE = $00000008;
  WINHTTP_ENABLE_SSL_REVOCATION = $00000001;
  WINHTTP_ENABLE_SSL_REVERT_IMPERSONATION = $00000002;
  WINHTTP_DISABLE_SPN_SERVER_PORT = $00000000;
  WINHTTP_ENABLE_SPN_SERVER_PORT = $00000001;
  WINHTTP_OPTION_SPN_MASK = WINHTTP_ENABLE_SPN_SERVER_PORT;

  { WinHTTP error codes  }
  WINHTTP_ERROR_BASE = 12000;
  ERROR_WINHTTP_OUT_OF_HANDLES = WINHTTP_ERROR_BASE + 1;
  ERROR_WINHTTP_TIMEOUT = WINHTTP_ERROR_BASE + 2;
  ERROR_WINHTTP_INTERNAL_ERROR = WINHTTP_ERROR_BASE + 4;
  ERROR_WINHTTP_INVALID_URL = WINHTTP_ERROR_BASE + 5;
  ERROR_WINHTTP_UNRECOGNIZED_SCHEME = WINHTTP_ERROR_BASE + 6;
  ERROR_WINHTTP_NAME_NOT_RESOLVED = WINHTTP_ERROR_BASE + 7;
  ERROR_WINHTTP_INVALID_OPTION = WINHTTP_ERROR_BASE + 9;
  ERROR_WINHTTP_OPTION_NOT_SETTABLE = WINHTTP_ERROR_BASE + 11;
  ERROR_WINHTTP_SHUTDOWN = WINHTTP_ERROR_BASE + 12;
  ERROR_WINHTTP_LOGIN_FAILURE = WINHTTP_ERROR_BASE + 15;
  ERROR_WINHTTP_OPERATION_CANCELLED = WINHTTP_ERROR_BASE + 17;
  ERROR_WINHTTP_INCORRECT_HANDLE_TYPE = WINHTTP_ERROR_BASE + 18;
  ERROR_WINHTTP_INCORRECT_HANDLE_STATE = WINHTTP_ERROR_BASE + 19;
  ERROR_WINHTTP_CANNOT_CONNECT = WINHTTP_ERROR_BASE + 29;
  ERROR_WINHTTP_CONNECTION_ERROR = WINHTTP_ERROR_BASE + 30;
  ERROR_WINHTTP_RESEND_REQUEST = WINHTTP_ERROR_BASE + 32;
  ERROR_WINHTTP_SECURE_CERT_DATE_INVALID = WINHTTP_ERROR_BASE + 37;
  ERROR_WINHTTP_SECURE_CERT_CN_INVALID = WINHTTP_ERROR_BASE + 38;
  ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED = WINHTTP_ERROR_BASE + 44;
  ERROR_WINHTTP_SECURE_INVALID_CA = WINHTTP_ERROR_BASE + 45;
  ERROR_WINHTTP_SECURE_CERT_REV_FAILED = WINHTTP_ERROR_BASE + 57;
  ERROR_WINHTTP_CANNOT_CALL_BEFORE_OPEN = WINHTTP_ERROR_BASE + 100;
  ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND = WINHTTP_ERROR_BASE + 101;
  ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND = WINHTTP_ERROR_BASE + 102;
  ERROR_WINHTTP_CANNOT_CALL_AFTER_OPEN = WINHTTP_ERROR_BASE + 103;
  ERROR_WINHTTP_HEADER_NOT_FOUND = WINHTTP_ERROR_BASE + 150;
  ERROR_WINHTTP_INVALID_SERVER_RESPONSE = WINHTTP_ERROR_BASE + 152;
  ERROR_WINHTTP_INVALID_HEADER = WINHTTP_ERROR_BASE + 153;
  ERROR_WINHTTP_INVALID_QUERY_REQUEST = WINHTTP_ERROR_BASE + 154;
  ERROR_WINHTTP_HEADER_ALREADY_EXISTS = WINHTTP_ERROR_BASE + 155;
  ERROR_WINHTTP_REDIRECT_FAILED = WINHTTP_ERROR_BASE + 156;
  ERROR_WINHTTP_SECURE_CHANNEL_ERROR = WINHTTP_ERROR_BASE + 157;
  ERROR_WINHTTP_BAD_AUTO_PROXY_SCRIPT = WINHTTP_ERROR_BASE + 166;
  ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT = WINHTTP_ERROR_BASE + 167;
  ERROR_WINHTTP_SECURE_INVALID_CERT = WINHTTP_ERROR_BASE + 169;
  ERROR_WINHTTP_SECURE_CERT_REVOKED = WINHTTP_ERROR_BASE + 170;
  ERROR_WINHTTP_NOT_INITIALIZED = WINHTTP_ERROR_BASE + 172;
  ERROR_WINHTTP_SECURE_FAILURE = WINHTTP_ERROR_BASE + 175;
  ERROR_WINHTTP_AUTO_PROXY_SERVICE_ERROR = WINHTTP_ERROR_BASE + 178;
  ERROR_WINHTTP_SECURE_CERT_WRONG_USAGE = WINHTTP_ERROR_BASE + 179;
  ERROR_WINHTTP_AUTODETECTION_FAILED = WINHTTP_ERROR_BASE + 180;
  ERROR_WINHTTP_HEADER_COUNT_EXCEEDED = WINHTTP_ERROR_BASE + 181;
  ERROR_WINHTTP_HEADER_SIZE_OVERFLOW = WINHTTP_ERROR_BASE + 182;
  ERROR_WINHTTP_CHUNKED_ENCODING_HEADER_SIZE_OVERFLOW = WINHTTP_ERROR_BASE + 183;
  ERROR_WINHTTP_RESPONSE_DRAIN_OVERFLOW = WINHTTP_ERROR_BASE + 184;
  ERROR_WINHTTP_CLIENT_CERT_NO_PRIVATE_KEY = WINHTTP_ERROR_BASE + 185;
  ERROR_WINHTTP_CLIENT_CERT_NO_ACCESS_PRIVATE_KEY = WINHTTP_ERROR_BASE + 186;
  WINHTTP_ERROR_LAST = WINHTTP_ERROR_BASE + 186;
  { WinHttp status codes  }
  HTTP_STATUS_CONTINUE = 100;
  HTTP_STATUS_SWITCH_PROTOCOLS = 101;
  HTTP_STATUS_OK = 200;
  HTTP_STATUS_CREATED = 201;
  HTTP_STATUS_ACCEPTED = 202;
  HTTP_STATUS_PARTIAL = 203;
  HTTP_STATUS_NO_CONTENT = 204;
  HTTP_STATUS_RESET_CONTENT = 205;
  HTTP_STATUS_PARTIAL_CONTENT = 206;
  HTTP_STATUS_WEBDAV_MULTI_STATUS = 207;
  HTTP_STATUS_AMBIGUOUS = 300;
  HTTP_STATUS_MOVED = 301;
  HTTP_STATUS_REDIRECT = 302;
  HTTP_STATUS_REDIRECT_METHOD = 303;
  HTTP_STATUS_NOT_MODIFIED = 304;
  HTTP_STATUS_USE_PROXY = 305;
  HTTP_STATUS_REDIRECT_KEEP_VERB = 307;
  HTTP_STATUS_BAD_REQUEST = 400;
  HTTP_STATUS_DENIED = 401;
  HTTP_STATUS_PAYMENT_REQ = 402;
  HTTP_STATUS_FORBIDDEN = 403;
  HTTP_STATUS_NOT_FOUND = 404;
  HTTP_STATUS_BAD_METHOD = 405;
  HTTP_STATUS_NONE_ACCEPTABLE = 406;
  HTTP_STATUS_PROXY_AUTH_REQ = 407;
  HTTP_STATUS_REQUEST_TIMEOUT = 408;
  HTTP_STATUS_CONFLICT = 409;
  HTTP_STATUS_GONE = 410;
  HTTP_STATUS_LENGTH_REQUIRED = 411;
  HTTP_STATUS_PRECOND_FAILED = 412;
  HTTP_STATUS_REQUEST_TOO_LARGE = 413;
  HTTP_STATUS_URI_TOO_LONG = 414;
  HTTP_STATUS_UNSUPPORTED_MEDIA = 415;
  HTTP_STATUS_RETRY_WITH = 449;
  HTTP_STATUS_SERVER_ERROR = 500;
  HTTP_STATUS_NOT_SUPPORTED = 501;
  HTTP_STATUS_BAD_GATEWAY = 502;
  HTTP_STATUS_SERVICE_UNAVAIL = 503;
  HTTP_STATUS_GATEWAY_TIMEOUT = 504;
  HTTP_STATUS_VERSION_NOT_SUP = 505;
  HTTP_STATUS_FIRST = HTTP_STATUS_CONTINUE;
  HTTP_STATUS_LAST = HTTP_STATUS_VERSION_NOT_SUP;
  SECURITY_FLAG_IGNORE_UNKNOWN_CA = $00000100;
  SECURITY_FLAG_IGNORE_CERT_DATE_INVALID = $00002000;
  SECURITY_FLAG_IGNORE_CERT_CN_INVALID = $00001000;
  SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE = $00000200;
  SECURITY_FLAG_SECURE = $00000001;
  SECURITY_FLAG_STRENGTH_WEAK = $10000000;
  SECURITY_FLAG_STRENGTH_MEDIUM = $40000000;
  SECURITY_FLAG_STRENGTH_STRONG = $20000000;
  ICU_NO_ENCODE = $20000000;
  ICU_DECODE = $10000000;
  ICU_NO_META = $08000000;
  ICU_ENCODE_SPACES_ONLY = $04000000;
  ICU_BROWSER_MODE = $02000000;
  ICU_ENCODE_PERCENT = $00001000;
  { Query flags  }
  WINHTTP_QUERY_MIME_VERSION = 0;
  WINHTTP_QUERY_CONTENT_TYPE = 1;
  WINHTTP_QUERY_CONTENT_TRANSFER_ENCODING = 2;
  WINHTTP_QUERY_CONTENT_ID = 3;
  WINHTTP_QUERY_CONTENT_DESCRIPTION = 4;
  WINHTTP_QUERY_CONTENT_LENGTH = 5;
  WINHTTP_QUERY_CONTENT_LANGUAGE = 6;
  WINHTTP_QUERY_ALLOW = 7;
  WINHTTP_QUERY_PUBLIC = 8;
  WINHTTP_QUERY_DATE = 9;
  WINHTTP_QUERY_EXPIRES = 10;
  WINHTTP_QUERY_LAST_MODIFIED = 11;
  WINHTTP_QUERY_MESSAGE_ID = 12;
  WINHTTP_QUERY_URI = 13;
  WINHTTP_QUERY_DERIVED_FROM = 14;
  WINHTTP_QUERY_COST = 15;
  WINHTTP_QUERY_LINK = 16;
  WINHTTP_QUERY_PRAGMA = 17;
  WINHTTP_QUERY_VERSION = 18;
  WINHTTP_QUERY_STATUS_CODE = 19;
  WINHTTP_QUERY_STATUS_TEXT = 20;
  WINHTTP_QUERY_RAW_HEADERS = 21;
  WINHTTP_QUERY_RAW_HEADERS_CRLF = 22;
  WINHTTP_QUERY_CONNECTION = 23;
  WINHTTP_QUERY_ACCEPT = 24;
  WINHTTP_QUERY_ACCEPT_CHARSET = 25;
  WINHTTP_QUERY_ACCEPT_ENCODING = 26;
  WINHTTP_QUERY_ACCEPT_LANGUAGE = 27;
  WINHTTP_QUERY_AUTHORIZATION = 28;
  WINHTTP_QUERY_CONTENT_ENCODING = 29;
  WINHTTP_QUERY_FORWARDED = 30;
  WINHTTP_QUERY_FROM = 31;
  WINHTTP_QUERY_IF_MODIFIED_SINCE = 32;
  WINHTTP_QUERY_LOCATION = 33;
  WINHTTP_QUERY_ORIG_URI = 34;
  WINHTTP_QUERY_REFERER = 35;
  WINHTTP_QUERY_RETRY_AFTER = 36;
  WINHTTP_QUERY_SERVER = 37;
  WINHTTP_QUERY_TITLE = 38;
  WINHTTP_QUERY_USER_AGENT = 39;
  WINHTTP_QUERY_WWW_AUTHENTICATE = 40;
  WINHTTP_QUERY_PROXY_AUTHENTICATE = 41;
  WINHTTP_QUERY_ACCEPT_RANGES = 42;
  WINHTTP_QUERY_SET_COOKIE = 43;
  WINHTTP_QUERY_COOKIE = 44;
  WINHTTP_QUERY_REQUEST_METHOD = 45;
  WINHTTP_QUERY_REFRESH = 46;
  WINHTTP_QUERY_CONTENT_DISPOSITION = 47;
  WINHTTP_QUERY_AGE = 48;
  WINHTTP_QUERY_CACHE_CONTROL = 49;
  WINHTTP_QUERY_CONTENT_BASE = 50;
  WINHTTP_QUERY_CONTENT_LOCATION = 51;
  WINHTTP_QUERY_CONTENT_MD5 = 52;
  WINHTTP_QUERY_CONTENT_RANGE = 53;
  WINHTTP_QUERY_ETAG = 54;
  WINHTTP_QUERY_HOST = 55;
  WINHTTP_QUERY_IF_MATCH = 56;
  WINHTTP_QUERY_IF_NONE_MATCH = 57;
  WINHTTP_QUERY_IF_RANGE = 58;
  WINHTTP_QUERY_IF_UNMODIFIED_SINCE = 59;
  WINHTTP_QUERY_MAX_FORWARDS = 60;
  WINHTTP_QUERY_PROXY_AUTHORIZATION = 61;
  WINHTTP_QUERY_RANGE = 62;
  WINHTTP_QUERY_TRANSFER_ENCODING = 63;
  WINHTTP_QUERY_UPGRADE = 64;
  WINHTTP_QUERY_VARY = 65;
  WINHTTP_QUERY_VIA = 66;
  WINHTTP_QUERY_WARNING = 67;
  WINHTTP_QUERY_EXPECT = 68;
  WINHTTP_QUERY_PROXY_CONNECTION = 69;
  WINHTTP_QUERY_UNLESS_MODIFIED_SINCE = 70;
  WINHTTP_QUERY_PROXY_SUPPORT = 75;
  WINHTTP_QUERY_AUTHENTICATION_INFO = 76;
  WINHTTP_QUERY_PASSPORT_URLS = 77;
  WINHTTP_QUERY_PASSPORT_CONFIG = 78;
  WINHTTP_QUERY_MAX = 78;
  WINHTTP_QUERY_CUSTOM = 65535;
  WINHTTP_QUERY_FLAG_REQUEST_HEADERS = $80000000;
  WINHTTP_QUERY_FLAG_SYSTEMTIME = $40000000;
  WINHTTP_QUERY_FLAG_NUMBER = $20000000;
  { Callback options  }
  WINHTTP_CALLBACK_STATUS_RESOLVING_NAME = $00000001;
  WINHTTP_CALLBACK_STATUS_NAME_RESOLVED = $00000002;
  WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER = $00000004;
  WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER = $00000008;
  WINHTTP_CALLBACK_STATUS_SENDING_REQUEST = $00000010;
  WINHTTP_CALLBACK_STATUS_REQUEST_SENT = $00000020;
  WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE = $00000040;
  WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED = $00000080;
  WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION = $00000100;
  WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED = $00000200;
  WINHTTP_CALLBACK_STATUS_HANDLE_CREATED = $00000400;
  WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING = $00000800;
  WINHTTP_CALLBACK_STATUS_DETECTING_PROXY = $00001000;
  WINHTTP_CALLBACK_STATUS_REDIRECT = $00004000;
  WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE = $00008000;
  WINHTTP_CALLBACK_STATUS_SECURE_FAILURE = $00010000;
  WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE = $00020000;
  WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE = $00040000;
  WINHTTP_CALLBACK_STATUS_READ_COMPLETE = $00080000;
  WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE = $00100000;
  WINHTTP_CALLBACK_STATUS_REQUEST_ERROR = $00200000;
  WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE = $00400000;
  WINHTTP_CALLBACK_FLAG_RESOLVE_NAME =
    WINHTTP_CALLBACK_STATUS_RESOLVING_NAME or WINHTTP_CALLBACK_STATUS_NAME_RESOLVED;
  WINHTTP_CALLBACK_FLAG_CONNECT_TO_SERVER =
    WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER or
    WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER;
  WINHTTP_CALLBACK_FLAG_SEND_REQUEST =
    WINHTTP_CALLBACK_STATUS_SENDING_REQUEST or WINHTTP_CALLBACK_STATUS_REQUEST_SENT;
  WINHTTP_CALLBACK_FLAG_RECEIVE_RESPONSE =
    WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE or WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED;
  WINHTTP_CALLBACK_FLAG_CLOSE_CONNECTION =
    WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION or WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED;
  WINHTTP_CALLBACK_FLAG_HANDLES =
    WINHTTP_CALLBACK_STATUS_HANDLE_CREATED or WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING;
  WINHTTP_CALLBACK_FLAG_DETECTING_PROXY = WINHTTP_CALLBACK_STATUS_DETECTING_PROXY;
  WINHTTP_CALLBACK_FLAG_REDIRECT = WINHTTP_CALLBACK_STATUS_REDIRECT;
  WINHTTP_CALLBACK_FLAG_INTERMEDIATE_RESPONSE =
    WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE;
  WINHTTP_CALLBACK_FLAG_SECURE_FAILURE = WINHTTP_CALLBACK_STATUS_SECURE_FAILURE;
  WINHTTP_CALLBACK_FLAG_SENDREQUEST_COMPLETE =
    WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE;
  WINHTTP_CALLBACK_FLAG_HEADERS_AVAILABLE = WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE;
  WINHTTP_CALLBACK_FLAG_DATA_AVAILABLE = WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE;
  WINHTTP_CALLBACK_FLAG_READ_COMPLETE = WINHTTP_CALLBACK_STATUS_READ_COMPLETE;
  WINHTTP_CALLBACK_FLAG_WRITE_COMPLETE = WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE;
  WINHTTP_CALLBACK_FLAG_REQUEST_ERROR = WINHTTP_CALLBACK_STATUS_REQUEST_ERROR;
  WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS =
    ((((WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE or
    WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE) or WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE) or
    WINHTTP_CALLBACK_STATUS_READ_COMPLETE) or WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE) or
    WINHTTP_CALLBACK_STATUS_REQUEST_ERROR;
  WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS = $ffffffff;

const
  API_RECEIVE_RESPONSE = 1;
  API_QUERY_DATA_AVAILABLE = 2;
  API_READ_DATA = 3;
  API_WRITE_DATA = 4;
  API_SEND_REQUEST = 5;
  WINHTTP_HANDLE_TYPE_SESSION = 1;
  WINHTTP_HANDLE_TYPE_CONNECT = 2;
  WINHTTP_HANDLE_TYPE_REQUEST = 3;
  WINHTTP_CALLBACK_STATUS_FLAG_CERT_REV_FAILED = $00000001;
  WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CERT = $00000002;
  WINHTTP_CALLBACK_STATUS_FLAG_CERT_REVOKED = $00000004;
  WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CA = $00000008;
  WINHTTP_CALLBACK_STATUS_FLAG_CERT_CN_INVALID = $00000010;
  WINHTTP_CALLBACK_STATUS_FLAG_CERT_DATE_INVALID = $00000020;
  WINHTTP_CALLBACK_STATUS_FLAG_CERT_WRONG_USAGE = $00000040;
  WINHTTP_CALLBACK_STATUS_FLAG_SECURITY_CHANNEL_ERROR = $80000000;
  WINHTTP_FLAG_SECURE_PROTOCOL_SSL2 = $00000008;
  WINHTTP_FLAG_SECURE_PROTOCOL_SSL3 = $00000020;
  WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 = $00000080;
  WINHTTP_FLAG_SECURE_PROTOCOL_ALL =
    (WINHTTP_FLAG_SECURE_PROTOCOL_SSL2 or WINHTTP_FLAG_SECURE_PROTOCOL_SSL3) or
    WINHTTP_FLAG_SECURE_PROTOCOL_TLS1;
  WINHTTP_AUTH_SCHEME_BASIC = $00000001;
  WINHTTP_AUTH_SCHEME_NTLM = $00000002;
  WINHTTP_AUTH_SCHEME_PASSPORT = $00000004;
  WINHTTP_AUTH_SCHEME_DIGEST = $00000008;
  WINHTTP_AUTH_SCHEME_NEGOTIATE = $00000010;
  WINHTTP_AUTH_TARGET_SERVER = $00000000;
  WINHTTP_AUTH_TARGET_PROXY = $00000001;
  WINHTTP_TIME_FORMAT_BUFSIZE = 62;

type
  PURL_COMPONENTS = ^URL_COMPONENTS;

  URL_COMPONENTS = record
    dwStructSize: DWORD;
    lpszScheme: LPWSTR;
    dwSchemeLength: DWORD;
    nScheme: INTERNET_SCHEME;
    lpszHostName: LPWSTR;
    dwHostNameLength: DWORD;
    nPort: INTERNET_PORT;
    lpszUserName: LPWSTR;
    dwUserNameLength: DWORD;
    lpszPassword: LPWSTR;
    dwPasswordLength: DWORD;
    lpszUrlPath: LPWSTR;
    dwUrlPathLength: DWORD;
    lpszExtraInfo: LPWSTR;
    dwExtraInfoLength: DWORD;
  end;
  LPURL_COMPONENTS = PURL_COMPONENTS;
  PLPURL_COMPONENTS = ^LPURL_COMPONENTS;

  PURL_COMPONENTSW = ^URL_COMPONENTSW;
  URL_COMPONENTSW = URL_COMPONENTS;

  PLPURL_COMPONENTSW = ^LPURL_COMPONENTSW;
  LPURL_COMPONENTSW = LPURL_COMPONENTS;

  PWINHTTP_ASYNC_RESULT = ^WINHTTP_ASYNC_RESULT;

  WINHTTP_ASYNC_RESULT = record
    dwResult: DWORD_PTR;
    dwError: DWORD;
  end;
  LPWINHTTP_ASYNC_RESULT = PWINHTTP_ASYNC_RESULT;
  PLPWINHTTP_ASYNC_RESULT = ^LPWINHTTP_ASYNC_RESULT;

  PWINHTTP_CERTIFICATE_INFO = ^WINHTTP_CERTIFICATE_INFO;

  WINHTTP_CERTIFICATE_INFO = record
    ftExpiry: FILETIME;
    ftStart: FILETIME;
    lpszSubjectInfo: LPWSTR;
    lpszIssuerInfo: LPWSTR;
    lpszProtocolName: LPWSTR;
    lpszSignatureAlgName: LPWSTR;
    lpszEncryptionAlgName: LPWSTR;
    dwKeySize: DWORD;
  end;

  PWINHTTP_PROXY_INFO = ^WINHTTP_PROXY_INFO;

  WINHTTP_PROXY_INFO = record
    dwAccessType: DWORD;
    lpszProxy: LPCWSTR;
    lpszProxyBypass: LPCWSTR;
  end;
  LPWINHTTP_PROXY_INFO = PWINHTTP_PROXY_INFO;
  PLPWINHTTP_PROXY_INFO = ^LPWINHTTP_PROXY_INFO;

  PWINHTTP_PROXY_INFOW = ^WINHTTP_PROXY_INFOW;
  WINHTTP_PROXY_INFOW = WINHTTP_PROXY_INFO;

  PLPWINHTTP_PROXY_INFOW = ^LPWINHTTP_PROXY_INFOW;
  LPWINHTTP_PROXY_INFOW = LPWINHTTP_PROXY_INFO;

  PWINHTTP_CURRENT_USER_IE_PROXY_CONFIG = ^WINHTTP_CURRENT_USER_IE_PROXY_CONFIG;

  WINHTTP_CURRENT_USER_IE_PROXY_CONFIG = record
    fAutoDetect: WINBOOL;
    lpszAutoConfigUrl: LPWSTR;
    lpszProxy: LPWSTR;
    lpszProxyBypass: LPWSTR;
  end;

  WINHTTP_STATUS_CALLBACK = procedure(hInterneth: HINTERNET;
    dwContext: DWORD_PTR; dwInternetStatus: DWORD; lpvStatusInformation: LPVOID;
    dwStatusInformationLength: DWORD); stdcall;

  PWINHTTP_AUTOPROXY_OPTIONS = ^WINHTTP_AUTOPROXY_OPTIONS;

  WINHTTP_AUTOPROXY_OPTIONS = record
    dwFlags: DWORD;
    dwAutoDetectFlags: DWORD;
    lpszAutoConfigUrl: LPCWSTR;
    lpvReserved: LPVOID;
    dwReserved: DWORD;
    fAutoLogonIfChallenged: WINBOOL;
  end;

  PHTTP_VERSION_INFO = ^HTTP_VERSION_INFO;

  HTTP_VERSION_INFO = record
    dwMajorVersion: DWORD;
    dwMinorVersion: DWORD;
  end;
  LPHTTP_VERSION_INFO = PHTTP_VERSION_INFO;
  PLPHTTP_VERSION_INFO = ^LPHTTP_VERSION_INFO;

function WINHTTP_INVALID_STATUS_CALLBACK: WINHTTP_STATUS_CALLBACK;
function WinHttpAddRequestHeaders(hRequest: HINTERNET; pwszHeaders: LPCWSTR;
  dwHeadersLength: DWORD; dwModifiers: DWORD): WINBOOL; stdcall;
  external LIB_WINHTTPDLL Name 'WinHttpAddRequestHeaders';
function WinHttpDetectAutoProxyConfigUrl(dwAutoDetectFlags: DWORD;
  ppwszAutoConfigUrl: PLPWSTR): WINBOOL; stdcall;
  external LIB_WINHTTPDLL Name 'WinHttpDetectAutoProxyConfigUrl';
function WinHttpCheckPlatform: WINBOOL; stdcall;
  external LIB_WINHTTPDLL Name 'WinHttpCheckPlatform';
function WinHttpCloseHandle(hInterneth: HINTERNET): WINBOOL; stdcall;
  external LIB_WINHTTPDLL Name 'WinHttpCloseHandle';
function WinHttpConnect(hSession: HINTERNET; pswzServerName: LPCWSTR;
  nServerPort: INTERNET_PORT; dwReserved: DWORD): HINTERNET; stdcall;
  external LIB_WINHTTPDLL Name 'WinHttpConnect';
function WinHttpCrackUrl(pwszUrl: LPCWSTR; dwUrlLength: DWORD;
  dwFlags: DWORD; lpUrlComponents: LPURL_COMPONENTS): WINBOOL; stdcall;
  external LIB_WINHTTPDLL Name 'WinHttpCrackUrl';
function WinHttpCreateUrl(lpUrlComponents: LPURL_COMPONENTS; dwFlags: DWORD;
  pwszUrl: LPWSTR; lpdwUrlLength: LPDWORD): WINBOOL; stdcall;
  external LIB_WINHTTPDLL Name 'WinHttpCreateUrl';
function WinHttpGetDefaultProxyConfiguration(pProxyInfo: PWINHTTP_PROXY_INFO): WINBOOL;
  stdcall; external LIB_WINHTTPDLL Name 'WinHttpGetDefaultProxyConfiguration';
function WinHttpGetIEProxyConfigForCurrentUser(pProxyConfig:
  PWINHTTP_CURRENT_USER_IE_PROXY_CONFIG): WINBOOL; stdcall;
  external LIB_WINHTTPDLL Name 'WinHttpGetIEProxyConfigForCurrentUser';
function WinHttpGetProxyForUrl(hSession: HINTERNET; lpcwszUrl: LPCWSTR;
  pAutoProxyOptions: PWINHTTP_AUTOPROXY_OPTIONS; pProxyInfo: PWINHTTP_PROXY_INFO): WINBOOL;
  stdcall; external LIB_WINHTTPDLL Name 'WinHttpGetProxyForUrl';
function WinHttpOpen(pwszUserAgent: LPCWSTR; dwAccessType: DWORD;
  pwszProxyName: LPCWSTR; pwszProxyBypass: LPCWSTR; dwFlags: DWORD): HINTERNET;
  stdcall; external LIB_WINHTTPDLL Name 'WinHttpOpen';
function WinHttpOpenRequest(hConnect: HINTERNET; pwszVerb: LPCWSTR;
  pwszObjectName: LPCWSTR; pwszVersion: LPCWSTR; pwszReferrer: LPCWSTR;
  ppwszAcceptTypes: LPCWSTR; dwFlags: DWORD): HINTERNET; stdcall;
  external LIB_WINHTTPDLL Name 'WinHttpOpenRequest';
function WinHttpQueryAuthParams(hRequest: HINTERNET; AuthScheme: DWORD;
  pAuthParams: LPVOID): WINBOOL; stdcall;
  external LIB_WINHTTPDLL Name 'WinHttpQueryAuthParams';
function WinHttpQueryAuthSchemes(hRequest: HINTERNET; lpdwSupportedSchemes: LPDWORD;
  lpdwFirstScheme: LPDWORD; pdwAuthTarget: LPDWORD): WINBOOL; stdcall;
  external LIB_WINHTTPDLL Name 'WinHttpQueryAuthSchemes';
function WinHttpQueryDataAvailable(hRequest: HINTERNET;
  lpdwNumberOfBytesAvailable: LPDWORD): WINBOOL; stdcall;
  external LIB_WINHTTPDLL Name 'WinHttpQueryDataAvailable';
function WinHttpQueryHeaders(hRequest: HINTERNET; dwInfoLevel: DWORD;
  pwszName: LPCWSTR; lpBuffer: LPVOID; lpdwBufferLength: LPDWORD;
  lpdwIndex: LPDWORD): WINBOOL; stdcall;
  external LIB_WINHTTPDLL Name 'WinHttpQueryHeaders';
function WinHttpQueryOption(hInterneth: HINTERNET; dwOption: DWORD;
  lpBuffer: LPVOID; lpdwBufferLength: LPDWORD): WINBOOL; stdcall;
  external LIB_WINHTTPDLL Name 'WinHttpQueryOption';
function WinHttpReadData(hRequest: HINTERNET; lpBuffer: LPVOID;
  dwNumberOfBytesToRead: DWORD; lpdwNumberOfBytesRead: LPDWORD): WINBOOL;
  stdcall; external LIB_WINHTTPDLL Name 'WinHttpReadData';
function WinHttpReceiveResponse(hRequest: HINTERNET; lpReserved: LPVOID): WINBOOL;
  stdcall; external LIB_WINHTTPDLL Name 'WinHttpReceiveResponse';
function WinHttpSendRequest(hRequest: HINTERNET; pwszHeaders: LPCWSTR;
  dwHeadersLength: DWORD; lpOptional: LPVOID; dwOptionalLength: DWORD;
  dwTotalLength: DWORD; dwContext: DWORD_PTR): WINBOOL; stdcall;
  external LIB_WINHTTPDLL Name 'WinHttpSendRequest';
function WinHttpSetDefaultProxyConfiguration(pProxyInfo: PWINHTTP_PROXY_INFO): WINBOOL;
  stdcall; external LIB_WINHTTPDLL Name 'WinHttpSetDefaultProxyConfiguration';
function WinHttpSetCredentials(hRequest: HINTERNET; AuthTargets: DWORD;
  AuthScheme: DWORD; pwszUserName: LPCWSTR; pwszPassword: LPCWSTR;
  pAuthParams: LPVOID): WINBOOL; stdcall;
  external LIB_WINHTTPDLL Name 'WinHttpSetCredentials';
function WinHttpSetOption(hInterneth: HINTERNET; dwOption: DWORD;
  lpBuffer: LPVOID; dwBufferLength: DWORD): WINBOOL; stdcall;
  external LIB_WINHTTPDLL Name 'WinHttpSetOption';
function WinHttpSetStatusCallback(hInterneth: HINTERNET;
  lpfnInternetCallback: WINHTTP_STATUS_CALLBACK; dwNotificationFlags: DWORD;
  dwReserved: DWORD_PTR): WINHTTP_STATUS_CALLBACK; stdcall;
  external LIB_WINHTTPDLL Name 'WinHttpSetStatusCallback';
function WinHttpSetTimeouts(hInterneth: HINTERNET; dwResolveTimeout: longint;
  dwConnectTimeout: longint; dwSendTimeout: longint; dwReceiveTimeout: longint): WINBOOL;
  stdcall; external LIB_WINHTTPDLL Name 'WinHttpSetTimeouts';
function WinHttpTimeFromSystemTime(pst: PSYSTEMTIME; pwszTime: LPWSTR): WINBOOL;
  stdcall; external LIB_WINHTTPDLL Name 'WinHttpTimeFromSystemTime';
function WinHttpTimeToSystemTime(pwszTime: LPCWSTR; pst: PSYSTEMTIME): WINBOOL;
  stdcall; external LIB_WINHTTPDLL Name 'WinHttpTimeToSystemTime';
function WinHttpWriteData(hRequest: HINTERNET; lpBuffer: LPCVOID;
  dwNumberOfBytesToWrite: DWORD; lpdwNumberOfBytesWritten: LPDWORD): WINBOOL;
  stdcall; external LIB_WINHTTPDLL Name 'WinHttpWriteData';

implementation

function WINHTTP_INVALID_STATUS_CALLBACK: WINHTTP_STATUS_CALLBACK;
begin
  WINHTTP_INVALID_STATUS_CALLBACK := WINHTTP_STATUS_CALLBACK(-(1));
end;

end.
winhttp.3.pas (28,257 bytes)

Thaddy de Koning

2017-07-08 11:42

reporter   ~0101599

I think you should take the winhttp.h from the official windows SDK.
I have my doubts if that particular license above is fully legal. It does not mention the original copyright holder: Microsoft.

Michael Van Canneyt

2017-07-08 13:28

administrator   ~0101602

I've really had it with these eternal license discussions.
Very demotivating for people. It's just headers, not code.

I took the original headers from Windows SDK,
ran them through h2pas and stuck the regular FPC license on it.
Added to winunits-base package.

Apologies to the original poster for wasting so much of his time.

Please test and close if OK.

Michal Gawrycki

2017-07-13 18:43

reporter   ~0101695

Tested. Thank you.

Issue History

Date Modified Username Field Change
2016-09-26 14:53 Michal Gawrycki New Issue
2016-09-26 14:53 Michal Gawrycki File Added: winhttp.pas
2016-09-26 16:11 Jonas Maebe Note Added: 0094822
2016-09-26 16:46 Michal Gawrycki Note Added: 0094823
2016-09-26 16:48 Michal Gawrycki File Added: winhttp.2.pas
2017-07-07 20:03 Michal Gawrycki File Added: winhttp.3.pas
2017-07-08 11:42 Thaddy de Koning Note Added: 0101599
2017-07-08 13:28 Michael Van Canneyt Fixed in Revision => 36677
2017-07-08 13:28 Michael Van Canneyt Note Added: 0101602
2017-07-08 13:28 Michael Van Canneyt Status new => resolved
2017-07-08 13:28 Michael Van Canneyt Fixed in Version => 3.1.1
2017-07-08 13:28 Michael Van Canneyt Resolution open => fixed
2017-07-08 13:28 Michael Van Canneyt Assigned To => Michael Van Canneyt
2017-07-08 13:28 Michael Van Canneyt Target Version => 3.2.0
2017-07-13 18:43 Michal Gawrycki Note Added: 0101695
2017-07-13 18:43 Michal Gawrycki Status resolved => closed
2019-09-29 18:29 LacaK Relationship added related to 0036106