cscg24-guacamole

CSCG 2024 Challenge 'Guacamole Mashup'
git clone https://git.sinitax.com/sinitax/cscg24-guacamole
Log | Files | Refs | sfeed.txt

winhttp.h (27771B)


      1/**
      2 * WinPR: Windows Portable Runtime
      3 * Windows HTTP (WinHTTP)
      4 *
      5 * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
      6 *
      7 * Licensed under the Apache License, Version 2.0 (the "License");
      8 * you may not use this file except in compliance with the License.
      9 * You may obtain a copy of the License at
     10 *
     11 *     http://www.apache.org/licenses/LICENSE-2.0
     12 *
     13 * Unless required by applicable law or agreed to in writing, software
     14 * distributed under the License is distributed on an "AS IS" BASIS,
     15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16 * See the License for the specific language governing permissions and
     17 * limitations under the License.
     18 */
     19
     20#ifndef WINPR_WINHTTP_H
     21#define WINPR_WINHTTP_H
     22
     23#include <winpr/winpr.h>
     24#include <winpr/wtypes.h>
     25#include <winpr/winsock.h>
     26
     27#if defined(_WIN32) && !defined(_UWP)
     28
     29#include <winhttp.h>
     30
     31#else
     32
     33typedef LPVOID HINTERNET;
     34typedef HINTERNET* LPHINTERNET;
     35
     36typedef WORD INTERNET_PORT;
     37typedef INTERNET_PORT* LPINTERNET_PORT;
     38
     39#define INTERNET_DEFAULT_PORT 0
     40#define INTERNET_DEFAULT_HTTP_PORT 80
     41#define INTERNET_DEFAULT_HTTPS_PORT 443
     42
     43#define WINHTTP_FLAG_ASYNC 0x10000000
     44
     45#define WINHTTP_FLAG_SECURE 0x00800000
     46#define WINHTTP_FLAG_ESCAPE_PERCENT 0x00000004
     47#define WINHTTP_FLAG_NULL_CODEPAGE 0x00000008
     48#define WINHTTP_FLAG_BYPASS_PROXY_CACHE 0x00000100
     49#define WINHTTP_FLAG_REFRESH WINHTTP_FLAG_BYPASS_PROXY_CACHE
     50#define WINHTTP_FLAG_ESCAPE_DISABLE 0x00000040
     51#define WINHTTP_FLAG_ESCAPE_DISABLE_QUERY 0x00000080
     52
     53#define SECURITY_FLAG_IGNORE_UNKNOWN_CA 0x00000100
     54#define SECURITY_FLAG_IGNORE_CERT_DATE_INVALID 0x00002000
     55#define SECURITY_FLAG_IGNORE_CERT_CN_INVALID 0x00001000
     56#define SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE 0x00000200
     57
     58typedef struct
     59{
     60	DWORD_PTR dwResult;
     61	DWORD dwError;
     62} WINHTTP_ASYNC_RESULT, *LPWINHTTP_ASYNC_RESULT;
     63
     64typedef struct
     65{
     66	DWORD dwMajorVersion;
     67	DWORD dwMinorVersion;
     68} HTTP_VERSION_INFO, *LPHTTP_VERSION_INFO;
     69
     70typedef int INTERNET_SCHEME, *LPINTERNET_SCHEME;
     71
     72#define INTERNET_SCHEME_HTTP (1)
     73#define INTERNET_SCHEME_HTTPS (2)
     74
     75typedef struct
     76{
     77	DWORD dwStructSize;
     78	LPWSTR lpszScheme;
     79	DWORD dwSchemeLength;
     80	INTERNET_SCHEME nScheme;
     81	LPWSTR lpszHostName;
     82	DWORD dwHostNameLength;
     83	INTERNET_PORT nPort;
     84	LPWSTR lpszUserName;
     85	DWORD dwUserNameLength;
     86	LPWSTR lpszPassword;
     87	DWORD dwPasswordLength;
     88	LPWSTR lpszUrlPath;
     89	DWORD dwUrlPathLength;
     90	LPWSTR lpszExtraInfo;
     91	DWORD dwExtraInfoLength;
     92} URL_COMPONENTS, *LPURL_COMPONENTS;
     93
     94typedef URL_COMPONENTS URL_COMPONENTSW;
     95typedef LPURL_COMPONENTS LPURL_COMPONENTSW;
     96
     97typedef struct
     98{
     99	DWORD dwAccessType;
    100	LPWSTR lpszProxy;
    101	LPWSTR lpszProxyBypass;
    102} WINHTTP_PROXY_INFO, *LPWINHTTP_PROXY_INFO;
    103
    104typedef WINHTTP_PROXY_INFO WINHTTP_PROXY_INFOW;
    105typedef LPWINHTTP_PROXY_INFO LPWINHTTP_PROXY_INFOW;
    106
    107typedef struct
    108{
    109	DWORD dwFlags;
    110	DWORD dwAutoDetectFlags;
    111	LPCWSTR lpszAutoConfigUrl;
    112	LPVOID lpvReserved;
    113	DWORD dwReserved;
    114	BOOL fAutoLogonIfChallenged;
    115} WINHTTP_AUTOPROXY_OPTIONS;
    116
    117#define WINHTTP_AUTOPROXY_AUTO_DETECT 0x00000001
    118#define WINHTTP_AUTOPROXY_CONFIG_URL 0x00000002
    119#define WINHTTP_AUTOPROXY_HOST_KEEPCASE 0x00000004
    120#define WINHTTP_AUTOPROXY_HOST_LOWERCASE 0x00000008
    121#define WINHTTP_AUTOPROXY_RUN_INPROCESS 0x00010000
    122#define WINHTTP_AUTOPROXY_RUN_OUTPROCESS_ONLY 0x00020000
    123
    124#define WINHTTP_AUTO_DETECT_TYPE_DHCP 0x00000001
    125#define WINHTTP_AUTO_DETECT_TYPE_DNS_A 0x00000002
    126
    127typedef struct
    128{
    129	FILETIME ftExpiry;
    130	FILETIME ftStart;
    131	LPWSTR lpszSubjectInfo;
    132	LPWSTR lpszIssuerInfo;
    133	LPWSTR lpszProtocolName;
    134	LPWSTR lpszSignatureAlgName;
    135	LPWSTR lpszEncryptionAlgName;
    136	DWORD dwKeySize;
    137} WINHTTP_CERTIFICATE_INFO;
    138
    139typedef struct
    140{
    141	DWORD cbSize;
    142	SOCKADDR_STORAGE LocalAddress;
    143	SOCKADDR_STORAGE RemoteAddress;
    144} WINHTTP_CONNECTION_INFO;
    145
    146#define WINHTTP_TIME_FORMAT_BUFSIZE 62
    147
    148#define ICU_NO_ENCODE 0x20000000
    149#define ICU_DECODE 0x10000000
    150#define ICU_NO_META 0x08000000
    151#define ICU_ENCODE_SPACES_ONLY 0x04000000
    152#define ICU_BROWSER_MODE 0x02000000
    153#define ICU_ENCODE_PERCENT 0x00001000
    154
    155#define ICU_ESCAPE 0x80000000
    156#define ICU_ESCAPE_AUTHORITY 0x00002000
    157#define ICU_REJECT_USERPWD 0x00004000
    158
    159#define WINHTTP_ACCESS_TYPE_DEFAULT_PROXY 0
    160#define WINHTTP_ACCESS_TYPE_NO_PROXY 1
    161#define WINHTTP_ACCESS_TYPE_NAMED_PROXY 3
    162
    163#define WINHTTP_NO_PROXY_NAME NULL
    164#define WINHTTP_NO_PROXY_BYPASS NULL
    165#define WINHTTP_NO_CLIENT_CERT_CONTEXT NULL
    166
    167#define WINHTTP_FIRST_OPTION WINHTTP_OPTION_CALLBACK
    168
    169#define WINHTTP_OPTION_CALLBACK 1
    170#define WINHTTP_OPTION_RESOLVE_TIMEOUT 2
    171#define WINHTTP_OPTION_CONNECT_TIMEOUT 3
    172#define WINHTTP_OPTION_CONNECT_RETRIES 4
    173#define WINHTTP_OPTION_SEND_TIMEOUT 5
    174#define WINHTTP_OPTION_RECEIVE_TIMEOUT 6
    175#define WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT 7
    176#define WINHTTP_OPTION_HANDLE_TYPE 9
    177#define WINHTTP_OPTION_READ_BUFFER_SIZE 12
    178#define WINHTTP_OPTION_WRITE_BUFFER_SIZE 13
    179#define WINHTTP_OPTION_PARENT_HANDLE 21
    180#define WINHTTP_OPTION_EXTENDED_ERROR 24
    181#define WINHTTP_OPTION_SECURITY_FLAGS 31
    182#define WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT 32
    183#define WINHTTP_OPTION_URL 34
    184#define WINHTTP_OPTION_SECURITY_KEY_BITNESS 36
    185#define WINHTTP_OPTION_PROXY 38
    186#define WINHTTP_OPTION_USER_AGENT 41
    187#define WINHTTP_OPTION_CONTEXT_VALUE 45
    188#define WINHTTP_OPTION_CLIENT_CERT_CONTEXT 47
    189#define WINHTTP_OPTION_REQUEST_PRIORITY 58
    190#define WINHTTP_OPTION_HTTP_VERSION 59
    191#define WINHTTP_OPTION_DISABLE_FEATURE 63
    192#define WINHTTP_OPTION_CODEPAGE 68
    193#define WINHTTP_OPTION_MAX_CONNS_PER_SERVER 73
    194#define WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER 74
    195#define WINHTTP_OPTION_AUTOLOGON_POLICY 77
    196#define WINHTTP_OPTION_SERVER_CERT_CONTEXT 78
    197#define WINHTTP_OPTION_ENABLE_FEATURE 79
    198#define WINHTTP_OPTION_WORKER_THREAD_COUNT 80
    199#define WINHTTP_OPTION_PASSPORT_COBRANDING_TEXT 81
    200#define WINHTTP_OPTION_PASSPORT_COBRANDING_URL 82
    201#define WINHTTP_OPTION_CONFIGURE_PASSPORT_AUTH 83
    202#define WINHTTP_OPTION_SECURE_PROTOCOLS 84
    203#define WINHTTP_OPTION_ENABLETRACING 85
    204#define WINHTTP_OPTION_PASSPORT_SIGN_OUT 86
    205#define WINHTTP_OPTION_PASSPORT_RETURN_URL 87
    206#define WINHTTP_OPTION_REDIRECT_POLICY 88
    207#define WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS 89
    208#define WINHTTP_OPTION_MAX_HTTP_STATUS_CONTINUE 90
    209#define WINHTTP_OPTION_MAX_RESPONSE_HEADER_SIZE 91
    210#define WINHTTP_OPTION_MAX_RESPONSE_DRAIN_SIZE 92
    211#define WINHTTP_OPTION_CONNECTION_INFO 93
    212#define WINHTTP_OPTION_CLIENT_CERT_ISSUER_LIST 94
    213#define WINHTTP_OPTION_SPN 96
    214#define WINHTTP_OPTION_GLOBAL_PROXY_CREDS 97
    215#define WINHTTP_OPTION_GLOBAL_SERVER_CREDS 98
    216#define WINHTTP_OPTION_UNLOAD_NOTIFY_EVENT 99
    217#define WINHTTP_OPTION_REJECT_USERPWD_IN_URL 100
    218#define WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS 101
    219#define WINHTTP_OPTION_RECEIVE_PROXY_CONNECT_RESPONSE 103
    220#define WINHTTP_OPTION_IS_PROXY_CONNECT_RESPONSE 104
    221#define WINHTTP_OPTION_SERVER_SPN_USED 106
    222#define WINHTTP_OPTION_PROXY_SPN_USED 107
    223#define WINHTTP_OPTION_SERVER_CBT 108
    224
    225#define WINHTTP_LAST_OPTION WINHTTP_OPTION_SERVER_CBT
    226
    227#define WINHTTP_OPTION_USERNAME 0x1000
    228#define WINHTTP_OPTION_PASSWORD 0x1001
    229#define WINHTTP_OPTION_PROXY_USERNAME 0x1002
    230#define WINHTTP_OPTION_PROXY_PASSWORD 0x1003
    231
    232#define WINHTTP_CONNS_PER_SERVER_UNLIMITED 0xFFFFFFFF
    233
    234#define WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM 0
    235#define WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW 1
    236#define WINHTTP_AUTOLOGON_SECURITY_LEVEL_HIGH 2
    237
    238#define WINHTTP_AUTOLOGON_SECURITY_LEVEL_DEFAULT WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM
    239
    240#define WINHTTP_OPTION_REDIRECT_POLICY_NEVER 0
    241#define WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP 1
    242#define WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS 2
    243
    244#define WINHTTP_OPTION_REDIRECT_POLICY_LAST WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS
    245#define WINHTTP_OPTION_REDIRECT_POLICY_DEFAULT WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP
    246
    247#define WINHTTP_DISABLE_PASSPORT_AUTH 0x00000000
    248#define WINHTTP_ENABLE_PASSPORT_AUTH 0x10000000
    249#define WINHTTP_DISABLE_PASSPORT_KEYRING 0x20000000
    250#define WINHTTP_ENABLE_PASSPORT_KEYRING 0x40000000
    251
    252#define WINHTTP_DISABLE_COOKIES 0x00000001
    253#define WINHTTP_DISABLE_REDIRECTS 0x00000002
    254#define WINHTTP_DISABLE_AUTHENTICATION 0x00000004
    255#define WINHTTP_DISABLE_KEEP_ALIVE 0x00000008
    256
    257#define WINHTTP_ENABLE_SSL_REVOCATION 0x00000001
    258#define WINHTTP_ENABLE_SSL_REVERT_IMPERSONATION 0x00000002
    259
    260#define WINHTTP_DISABLE_SPN_SERVER_PORT 0x00000000
    261#define WINHTTP_ENABLE_SPN_SERVER_PORT 0x00000001
    262#define WINHTTP_OPTION_SPN_MASK WINHTTP_ENABLE_SPN_SERVER_PORT
    263
    264typedef struct tagWINHTTP_CREDS
    265{
    266	LPSTR lpszUserName;
    267	LPSTR lpszPassword;
    268	LPSTR lpszRealm;
    269	DWORD dwAuthScheme;
    270	LPSTR lpszHostName;
    271	DWORD dwPort;
    272} WINHTTP_CREDS, *PWINHTTP_CREDS;
    273
    274typedef struct tagWINHTTP_CREDS_EX
    275{
    276	LPSTR lpszUserName;
    277	LPSTR lpszPassword;
    278	LPSTR lpszRealm;
    279	DWORD dwAuthScheme;
    280	LPSTR lpszHostName;
    281	DWORD dwPort;
    282	LPSTR lpszUrl;
    283} WINHTTP_CREDS_EX, *PWINHTTP_CREDS_EX;
    284
    285#define WINHTTP_HANDLE_TYPE_SESSION 1
    286#define WINHTTP_HANDLE_TYPE_CONNECT 2
    287#define WINHTTP_HANDLE_TYPE_REQUEST 3
    288
    289#define WINHTTP_AUTH_SCHEME_BASIC 0x00000001
    290#define WINHTTP_AUTH_SCHEME_NTLM 0x00000002
    291#define WINHTTP_AUTH_SCHEME_PASSPORT 0x00000004
    292#define WINHTTP_AUTH_SCHEME_DIGEST 0x00000008
    293#define WINHTTP_AUTH_SCHEME_NEGOTIATE 0x00000010
    294
    295#define WINHTTP_AUTH_TARGET_SERVER 0x00000000
    296#define WINHTTP_AUTH_TARGET_PROXY 0x00000001
    297
    298#define SECURITY_FLAG_SECURE 0x00000001
    299#define SECURITY_FLAG_STRENGTH_WEAK 0x10000000
    300#define SECURITY_FLAG_STRENGTH_MEDIUM 0x40000000
    301#define SECURITY_FLAG_STRENGTH_STRONG 0x20000000
    302
    303#define WINHTTP_CALLBACK_STATUS_FLAG_CERT_REV_FAILED 0x00000001
    304#define WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CERT 0x00000002
    305#define WINHTTP_CALLBACK_STATUS_FLAG_CERT_REVOKED 0x00000004
    306#define WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CA 0x00000008
    307#define WINHTTP_CALLBACK_STATUS_FLAG_CERT_CN_INVALID 0x00000010
    308#define WINHTTP_CALLBACK_STATUS_FLAG_CERT_DATE_INVALID 0x00000020
    309#define WINHTTP_CALLBACK_STATUS_FLAG_CERT_WRONG_USAGE 0x00000040
    310#define WINHTTP_CALLBACK_STATUS_FLAG_SECURITY_CHANNEL_ERROR 0x80000000
    311
    312#define WINHTTP_FLAG_SECURE_PROTOCOL_SSL2 0x00000008
    313#define WINHTTP_FLAG_SECURE_PROTOCOL_SSL3 0x00000020
    314#define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 0x00000080
    315#define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 0x00000200
    316#define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2 0x00000800
    317#define WINHTTP_FLAG_SECURE_PROTOCOL_ALL                                     \
    318	(WINHTTP_FLAG_SECURE_PROTOCOL_SSL2 | WINHTTP_FLAG_SECURE_PROTOCOL_SSL3 | \
    319	 WINHTTP_FLAG_SECURE_PROTOCOL_TLS1)
    320
    321typedef VOID(CALLBACK* WINHTTP_STATUS_CALLBACK)(HINTERNET hInternet, DWORD_PTR dwContext,
    322                                                DWORD dwInternetStatus, LPVOID lpvStatusInformation,
    323                                                DWORD dwStatusInformationLength);
    324
    325typedef WINHTTP_STATUS_CALLBACK* LPWINHTTP_STATUS_CALLBACK;
    326
    327#define WINHTTP_CALLBACK_STATUS_RESOLVING_NAME 0x00000001
    328#define WINHTTP_CALLBACK_STATUS_NAME_RESOLVED 0x00000002
    329#define WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER 0x00000004
    330#define WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER 0x00000008
    331#define WINHTTP_CALLBACK_STATUS_SENDING_REQUEST 0x00000010
    332#define WINHTTP_CALLBACK_STATUS_REQUEST_SENT 0x00000020
    333#define WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE 0x00000040
    334#define WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED 0x00000080
    335#define WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION 0x00000100
    336#define WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED 0x00000200
    337#define WINHTTP_CALLBACK_STATUS_HANDLE_CREATED 0x00000400
    338#define WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING 0x00000800
    339#define WINHTTP_CALLBACK_STATUS_DETECTING_PROXY 0x00001000
    340#define WINHTTP_CALLBACK_STATUS_REDIRECT 0x00004000
    341#define WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE 0x00008000
    342#define WINHTTP_CALLBACK_STATUS_SECURE_FAILURE 0x00010000
    343#define WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE 0x00020000
    344#define WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE 0x00040000
    345#define WINHTTP_CALLBACK_STATUS_READ_COMPLETE 0x00080000
    346#define WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE 0x00100000
    347#define WINHTTP_CALLBACK_STATUS_REQUEST_ERROR 0x00200000
    348#define WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE 0x00400000
    349
    350#define API_RECEIVE_RESPONSE (1)
    351#define API_QUERY_DATA_AVAILABLE (2)
    352#define API_READ_DATA (3)
    353#define API_WRITE_DATA (4)
    354#define API_SEND_REQUEST (5)
    355
    356#define WINHTTP_CALLBACK_FLAG_RESOLVE_NAME \
    357	(WINHTTP_CALLBACK_STATUS_RESOLVING_NAME | WINHTTP_CALLBACK_STATUS_NAME_RESOLVED)
    358#define WINHTTP_CALLBACK_FLAG_CONNECT_TO_SERVER \
    359	(WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER | WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER)
    360#define WINHTTP_CALLBACK_FLAG_SEND_REQUEST \
    361	(WINHTTP_CALLBACK_STATUS_SENDING_REQUEST | WINHTTP_CALLBACK_STATUS_REQUEST_SENT)
    362#define WINHTTP_CALLBACK_FLAG_RECEIVE_RESPONSE \
    363	(WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE | WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED)
    364#define WINHTTP_CALLBACK_FLAG_CLOSE_CONNECTION \
    365	(WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION | WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED)
    366#define WINHTTP_CALLBACK_FLAG_HANDLES \
    367	(WINHTTP_CALLBACK_STATUS_HANDLE_CREATED | WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING)
    368#define WINHTTP_CALLBACK_FLAG_DETECTING_PROXY WINHTTP_CALLBACK_STATUS_DETECTING_PROXY
    369#define WINHTTP_CALLBACK_FLAG_REDIRECT WINHTTP_CALLBACK_STATUS_REDIRECT
    370#define WINHTTP_CALLBACK_FLAG_INTERMEDIATE_RESPONSE WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE
    371#define WINHTTP_CALLBACK_FLAG_SECURE_FAILURE WINHTTP_CALLBACK_STATUS_SECURE_FAILURE
    372#define WINHTTP_CALLBACK_FLAG_SENDREQUEST_COMPLETE WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE
    373#define WINHTTP_CALLBACK_FLAG_HEADERS_AVAILABLE WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE
    374#define WINHTTP_CALLBACK_FLAG_DATA_AVAILABLE WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE
    375#define WINHTTP_CALLBACK_FLAG_READ_COMPLETE WINHTTP_CALLBACK_STATUS_READ_COMPLETE
    376#define WINHTTP_CALLBACK_FLAG_WRITE_COMPLETE WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE
    377#define WINHTTP_CALLBACK_FLAG_REQUEST_ERROR WINHTTP_CALLBACK_STATUS_REQUEST_ERROR
    378
    379#define WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS                                                   \
    380	(WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE | WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE | \
    381	 WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE | WINHTTP_CALLBACK_STATUS_READ_COMPLETE |           \
    382	 WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE | WINHTTP_CALLBACK_STATUS_REQUEST_ERROR)
    383
    384#define WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS 0xFFFFFFFF
    385
    386#define WINHTTP_INVALID_STATUS_CALLBACK ((WINHTTP_STATUS_CALLBACK)(-1L))
    387
    388#define WINHTTP_QUERY_MIME_VERSION 0
    389#define WINHTTP_QUERY_CONTENT_TYPE 1
    390#define WINHTTP_QUERY_CONTENT_TRANSFER_ENCODING 2
    391#define WINHTTP_QUERY_CONTENT_ID 3
    392#define WINHTTP_QUERY_CONTENT_DESCRIPTION 4
    393#define WINHTTP_QUERY_CONTENT_LENGTH 5
    394#define WINHTTP_QUERY_CONTENT_LANGUAGE 6
    395#define WINHTTP_QUERY_ALLOW 7
    396#define WINHTTP_QUERY_PUBLIC 8
    397#define WINHTTP_QUERY_DATE 9
    398#define WINHTTP_QUERY_EXPIRES 10
    399#define WINHTTP_QUERY_LAST_MODIFIED 11
    400#define WINHTTP_QUERY_MESSAGE_ID 12
    401#define WINHTTP_QUERY_URI 13
    402#define WINHTTP_QUERY_DERIVED_FROM 14
    403#define WINHTTP_QUERY_COST 15
    404#define WINHTTP_QUERY_LINK 16
    405#define WINHTTP_QUERY_PRAGMA 17
    406#define WINHTTP_QUERY_VERSION 18
    407#define WINHTTP_QUERY_STATUS_CODE 19
    408#define WINHTTP_QUERY_STATUS_TEXT 20
    409#define WINHTTP_QUERY_RAW_HEADERS 21
    410#define WINHTTP_QUERY_RAW_HEADERS_CRLF 22
    411#define WINHTTP_QUERY_CONNECTION 23
    412#define WINHTTP_QUERY_ACCEPT 24
    413#define WINHTTP_QUERY_ACCEPT_CHARSET 25
    414#define WINHTTP_QUERY_ACCEPT_ENCODING 26
    415#define WINHTTP_QUERY_ACCEPT_LANGUAGE 27
    416#define WINHTTP_QUERY_AUTHORIZATION 28
    417#define WINHTTP_QUERY_CONTENT_ENCODING 29
    418#define WINHTTP_QUERY_FORWARDED 30
    419#define WINHTTP_QUERY_FROM 31
    420#define WINHTTP_QUERY_IF_MODIFIED_SINCE 32
    421#define WINHTTP_QUERY_LOCATION 33
    422#define WINHTTP_QUERY_ORIG_URI 34
    423#define WINHTTP_QUERY_REFERER 35
    424#define WINHTTP_QUERY_RETRY_AFTER 36
    425#define WINHTTP_QUERY_SERVER 37
    426#define WINHTTP_QUERY_TITLE 38
    427#define WINHTTP_QUERY_USER_AGENT 39
    428#define WINHTTP_QUERY_WWW_AUTHENTICATE 40
    429#define WINHTTP_QUERY_PROXY_AUTHENTICATE 41
    430#define WINHTTP_QUERY_ACCEPT_RANGES 42
    431#define WINHTTP_QUERY_SET_COOKIE 43
    432#define WINHTTP_QUERY_COOKIE 44
    433#define WINHTTP_QUERY_REQUEST_METHOD 45
    434#define WINHTTP_QUERY_REFRESH 46
    435#define WINHTTP_QUERY_CONTENT_DISPOSITION 47
    436#define WINHTTP_QUERY_AGE 48
    437#define WINHTTP_QUERY_CACHE_CONTROL 49
    438#define WINHTTP_QUERY_CONTENT_BASE 50
    439#define WINHTTP_QUERY_CONTENT_LOCATION 51
    440#define WINHTTP_QUERY_CONTENT_MD5 52
    441#define WINHTTP_QUERY_CONTENT_RANGE 53
    442#define WINHTTP_QUERY_ETAG 54
    443#define WINHTTP_QUERY_HOST 55
    444#define WINHTTP_QUERY_IF_MATCH 56
    445#define WINHTTP_QUERY_IF_NONE_MATCH 57
    446#define WINHTTP_QUERY_IF_RANGE 58
    447#define WINHTTP_QUERY_IF_UNMODIFIED_SINCE 59
    448#define WINHTTP_QUERY_MAX_FORWARDS 60
    449#define WINHTTP_QUERY_PROXY_AUTHORIZATION 61
    450#define WINHTTP_QUERY_RANGE 62
    451#define WINHTTP_QUERY_TRANSFER_ENCODING 63
    452#define WINHTTP_QUERY_UPGRADE 64
    453#define WINHTTP_QUERY_VARY 65
    454#define WINHTTP_QUERY_VIA 66
    455#define WINHTTP_QUERY_WARNING 67
    456#define WINHTTP_QUERY_EXPECT 68
    457#define WINHTTP_QUERY_PROXY_CONNECTION 69
    458#define WINHTTP_QUERY_UNLESS_MODIFIED_SINCE 70
    459#define WINHTTP_QUERY_PROXY_SUPPORT 75
    460#define WINHTTP_QUERY_AUTHENTICATION_INFO 76
    461#define WINHTTP_QUERY_PASSPORT_URLS 77
    462#define WINHTTP_QUERY_PASSPORT_CONFIG 78
    463#define WINHTTP_QUERY_MAX 78
    464#define WINHTTP_QUERY_CUSTOM 65535
    465#define WINHTTP_QUERY_FLAG_REQUEST_HEADERS 0x80000000
    466#define WINHTTP_QUERY_FLAG_SYSTEMTIME 0x40000000
    467#define WINHTTP_QUERY_FLAG_NUMBER 0x20000000
    468
    469#define HTTP_STATUS_CONTINUE 100
    470#define HTTP_STATUS_SWITCH_PROTOCOLS 101
    471
    472#define HTTP_STATUS_OK 200
    473#define HTTP_STATUS_CREATED 201
    474#define HTTP_STATUS_ACCEPTED 202
    475#define HTTP_STATUS_PARTIAL 203
    476#define HTTP_STATUS_NO_CONTENT 204
    477#define HTTP_STATUS_RESET_CONTENT 205
    478#define HTTP_STATUS_PARTIAL_CONTENT 206
    479#define HTTP_STATUS_WEBDAV_MULTI_STATUS 207
    480
    481#define HTTP_STATUS_AMBIGUOUS 300
    482#define HTTP_STATUS_MOVED 301
    483#define HTTP_STATUS_REDIRECT 302
    484#define HTTP_STATUS_REDIRECT_METHOD 303
    485#define HTTP_STATUS_NOT_MODIFIED 304
    486#define HTTP_STATUS_USE_PROXY 305
    487#define HTTP_STATUS_REDIRECT_KEEP_VERB 307
    488
    489#define HTTP_STATUS_BAD_REQUEST 400
    490#define HTTP_STATUS_DENIED 401
    491#define HTTP_STATUS_PAYMENT_REQ 402
    492#define HTTP_STATUS_FORBIDDEN 403
    493#define HTTP_STATUS_NOT_FOUND 404
    494#define HTTP_STATUS_BAD_METHOD 405
    495#define HTTP_STATUS_NONE_ACCEPTABLE 406
    496#define HTTP_STATUS_PROXY_AUTH_REQ 407
    497#define HTTP_STATUS_REQUEST_TIMEOUT 408
    498#define HTTP_STATUS_CONFLICT 409
    499#define HTTP_STATUS_GONE 410
    500#define HTTP_STATUS_LENGTH_REQUIRED 411
    501#define HTTP_STATUS_PRECOND_FAILED 412
    502#define HTTP_STATUS_REQUEST_TOO_LARGE 413
    503#define HTTP_STATUS_URI_TOO_LONG 414
    504#define HTTP_STATUS_UNSUPPORTED_MEDIA 415
    505#define HTTP_STATUS_RETRY_WITH 449
    506
    507#define HTTP_STATUS_SERVER_ERROR 500
    508#define HTTP_STATUS_NOT_SUPPORTED 501
    509#define HTTP_STATUS_BAD_GATEWAY 502
    510#define HTTP_STATUS_SERVICE_UNAVAIL 503
    511#define HTTP_STATUS_GATEWAY_TIMEOUT 504
    512#define HTTP_STATUS_VERSION_NOT_SUP 505
    513
    514#define HTTP_STATUS_FIRST HTTP_STATUS_CONTINUE
    515#define HTTP_STATUS_LAST HTTP_STATUS_VERSION_NOT_SUP
    516
    517#define WINHTTP_NO_REFERER NULL
    518#define WINHTTP_DEFAULT_ACCEPT_TYPES NULL
    519
    520#define WINHTTP_ADDREQ_INDEX_MASK 0x0000FFFF
    521#define WINHTTP_ADDREQ_FLAGS_MASK 0xFFFF0000
    522#define WINHTTP_ADDREQ_FLAG_ADD_IF_NEW 0x10000000
    523#define WINHTTP_ADDREQ_FLAG_ADD 0x20000000
    524#define WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA 0x40000000
    525#define WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON 0x01000000
    526#define WINHTTP_ADDREQ_FLAG_COALESCE WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA
    527#define WINHTTP_ADDREQ_FLAG_REPLACE 0x80000000
    528#define WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH 0
    529
    530#define WINHTTP_NO_ADDITIONAL_HEADERS NULL
    531#define WINHTTP_NO_REQUEST_DATA NULL
    532
    533#define WINHTTP_HEADER_NAME_BY_INDEX NULL
    534#define WINHTTP_NO_OUTPUT_BUFFER NULL
    535#define WINHTTP_NO_HEADER_INDEX NULL
    536
    537typedef struct
    538{
    539	BOOL fAutoDetect;
    540	LPWSTR lpszAutoConfigUrl;
    541	LPWSTR lpszProxy;
    542	LPWSTR lpszProxyBypass;
    543} WINHTTP_CURRENT_USER_IE_PROXY_CONFIG;
    544
    545#define WINHTTP_ERROR_BASE 12000
    546
    547#define ERROR_WINHTTP_OUT_OF_HANDLES (WINHTTP_ERROR_BASE + 1)
    548#define ERROR_WINHTTP_TIMEOUT (WINHTTP_ERROR_BASE + 2)
    549#define ERROR_WINHTTP_INTERNAL_ERROR (WINHTTP_ERROR_BASE + 4)
    550#define ERROR_WINHTTP_INVALID_URL (WINHTTP_ERROR_BASE + 5)
    551#define ERROR_WINHTTP_UNRECOGNIZED_SCHEME (WINHTTP_ERROR_BASE + 6)
    552#define ERROR_WINHTTP_NAME_NOT_RESOLVED (WINHTTP_ERROR_BASE + 7)
    553#define ERROR_WINHTTP_INVALID_OPTION (WINHTTP_ERROR_BASE + 9)
    554#define ERROR_WINHTTP_OPTION_NOT_SETTABLE (WINHTTP_ERROR_BASE + 11)
    555#define ERROR_WINHTTP_SHUTDOWN (WINHTTP_ERROR_BASE + 12)
    556#define ERROR_WINHTTP_LOGIN_FAILURE (WINHTTP_ERROR_BASE + 15)
    557#define ERROR_WINHTTP_OPERATION_CANCELLED (WINHTTP_ERROR_BASE + 17)
    558#define ERROR_WINHTTP_INCORRECT_HANDLE_TYPE (WINHTTP_ERROR_BASE + 18)
    559#define ERROR_WINHTTP_INCORRECT_HANDLE_STATE (WINHTTP_ERROR_BASE + 19)
    560#define ERROR_WINHTTP_CANNOT_CONNECT (WINHTTP_ERROR_BASE + 29)
    561#define ERROR_WINHTTP_CONNECTION_ERROR (WINHTTP_ERROR_BASE + 30)
    562#define ERROR_WINHTTP_RESEND_REQUEST (WINHTTP_ERROR_BASE + 32)
    563#define ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED (WINHTTP_ERROR_BASE + 44)
    564#define ERROR_WINHTTP_CANNOT_CALL_BEFORE_OPEN (WINHTTP_ERROR_BASE + 100)
    565#define ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND (WINHTTP_ERROR_BASE + 101)
    566#define ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND (WINHTTP_ERROR_BASE + 102)
    567#define ERROR_WINHTTP_CANNOT_CALL_AFTER_OPEN (WINHTTP_ERROR_BASE + 103)
    568#define ERROR_WINHTTP_HEADER_NOT_FOUND (WINHTTP_ERROR_BASE + 150)
    569#define ERROR_WINHTTP_INVALID_SERVER_RESPONSE (WINHTTP_ERROR_BASE + 152)
    570#define ERROR_WINHTTP_INVALID_HEADER (WINHTTP_ERROR_BASE + 153)
    571#define ERROR_WINHTTP_INVALID_QUERY_REQUEST (WINHTTP_ERROR_BASE + 154)
    572#define ERROR_WINHTTP_HEADER_ALREADY_EXISTS (WINHTTP_ERROR_BASE + 155)
    573#define ERROR_WINHTTP_REDIRECT_FAILED (WINHTTP_ERROR_BASE + 156)
    574#define ERROR_WINHTTP_AUTO_PROXY_SERVICE_ERROR (WINHTTP_ERROR_BASE + 178)
    575#define ERROR_WINHTTP_BAD_AUTO_PROXY_SCRIPT (WINHTTP_ERROR_BASE + 166)
    576#define ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT (WINHTTP_ERROR_BASE + 167)
    577#define ERROR_WINHTTP_NOT_INITIALIZED (WINHTTP_ERROR_BASE + 172)
    578#define ERROR_WINHTTP_SECURE_FAILURE (WINHTTP_ERROR_BASE + 175)
    579#define ERROR_WINHTTP_SECURE_CERT_DATE_INVALID (WINHTTP_ERROR_BASE + 37)
    580#define ERROR_WINHTTP_SECURE_CERT_CN_INVALID (WINHTTP_ERROR_BASE + 38)
    581#define ERROR_WINHTTP_SECURE_INVALID_CA (WINHTTP_ERROR_BASE + 45)
    582#define ERROR_WINHTTP_SECURE_CERT_REV_FAILED (WINHTTP_ERROR_BASE + 57)
    583#define ERROR_WINHTTP_SECURE_CHANNEL_ERROR (WINHTTP_ERROR_BASE + 157)
    584#define ERROR_WINHTTP_SECURE_INVALID_CERT (WINHTTP_ERROR_BASE + 169)
    585#define ERROR_WINHTTP_SECURE_CERT_REVOKED (WINHTTP_ERROR_BASE + 170)
    586#define ERROR_WINHTTP_SECURE_CERT_WRONG_USAGE (WINHTTP_ERROR_BASE + 179)
    587#define ERROR_WINHTTP_AUTODETECTION_FAILED (WINHTTP_ERROR_BASE + 180)
    588#define ERROR_WINHTTP_HEADER_COUNT_EXCEEDED (WINHTTP_ERROR_BASE + 181)
    589#define ERROR_WINHTTP_HEADER_SIZE_OVERFLOW (WINHTTP_ERROR_BASE + 182)
    590#define ERROR_WINHTTP_CHUNKED_ENCODING_HEADER_SIZE_OVERFLOW (WINHTTP_ERROR_BASE + 183)
    591#define ERROR_WINHTTP_RESPONSE_DRAIN_OVERFLOW (WINHTTP_ERROR_BASE + 184)
    592#define ERROR_WINHTTP_CLIENT_CERT_NO_PRIVATE_KEY (WINHTTP_ERROR_BASE + 185)
    593#define ERROR_WINHTTP_CLIENT_CERT_NO_ACCESS_PRIVATE_KEY (WINHTTP_ERROR_BASE + 186)
    594
    595#define WINHTTP_ERROR_LAST (WINHTTP_ERROR_BASE + 186)
    596
    597#ifdef __cplusplus
    598extern "C"
    599{
    600#endif
    601
    602	WINPR_API BOOL WinHttpTimeFromSystemTime(const SYSTEMTIME* pst, LPWSTR pwszTime);
    603	WINPR_API BOOL WinHttpTimeToSystemTime(LPCWSTR pwszTime, SYSTEMTIME* pst);
    604
    605	WINPR_API BOOL WinHttpCrackUrl(LPCWSTR pwszUrl, DWORD dwUrlLength, DWORD dwFlags,
    606	                               LPURL_COMPONENTS lpUrlComponents);
    607	WINPR_API BOOL WinHttpCreateUrl(LPURL_COMPONENTS lpUrlComponents, DWORD dwFlags, LPWSTR pwszUrl,
    608	                                LPDWORD pdwUrlLength);
    609
    610	WINPR_API BOOL WinHttpCheckPlatform(void);
    611
    612	WINPR_API BOOL WinHttpGetDefaultProxyConfiguration(WINHTTP_PROXY_INFO* pProxyInfo);
    613	WINPR_API BOOL WinHttpSetDefaultProxyConfiguration(WINHTTP_PROXY_INFO* pProxyInfo);
    614
    615	WINPR_API HINTERNET WinHttpOpen(LPCWSTR pszAgentW, DWORD dwAccessType, LPCWSTR pszProxyW,
    616	                                LPCWSTR pszProxyBypassW, DWORD dwFlags);
    617
    618	WINPR_API BOOL WinHttpCloseHandle(HINTERNET hInternet);
    619
    620	WINPR_API HINTERNET WinHttpConnect(HINTERNET hSession, LPCWSTR pswzServerName,
    621	                                   INTERNET_PORT nServerPort, DWORD dwReserved);
    622
    623	WINPR_API BOOL WinHttpReadData(HINTERNET hRequest, LPVOID lpBuffer, DWORD dwNumberOfBytesToRead,
    624	                               LPDWORD lpdwNumberOfBytesRead);
    625	WINPR_API BOOL WinHttpWriteData(HINTERNET hRequest, LPCVOID lpBuffer,
    626	                                DWORD dwNumberOfBytesToWrite, LPDWORD lpdwNumberOfBytesWritten);
    627
    628	WINPR_API BOOL WinHttpQueryDataAvailable(HINTERNET hRequest,
    629	                                         LPDWORD lpdwNumberOfBytesAvailable);
    630	WINPR_API BOOL WinHttpQueryOption(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer,
    631	                                  LPDWORD lpdwBufferLength);
    632
    633	WINPR_API BOOL WinHttpSetOption(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer,
    634	                                DWORD dwBufferLength);
    635	WINPR_API BOOL WinHttpSetTimeouts(HINTERNET hInternet, int nResolveTimeout, int nConnectTimeout,
    636	                                  int nSendTimeout, int nReceiveTimeout);
    637
    638	WINPR_API DWORD WinHttpIsHostInProxyBypassList(const WINHTTP_PROXY_INFO* pProxyInfo,
    639	                                               PCWSTR pwszHost, INTERNET_SCHEME tScheme,
    640	                                               INTERNET_PORT nPort, BOOL* pfIsInBypassList);
    641
    642	WINPR_API WINHTTP_STATUS_CALLBACK
    643	WinHttpSetStatusCallback(HINTERNET hInternet, WINHTTP_STATUS_CALLBACK lpfnInternetCallback,
    644	                         DWORD dwNotificationFlags, DWORD_PTR dwReserved);
    645
    646	WINPR_API HINTERNET WinHttpOpenRequest(HINTERNET hConnect, LPCWSTR pwszVerb,
    647	                                       LPCWSTR pwszObjectName, LPCWSTR pwszVersion,
    648	                                       LPCWSTR pwszReferrer, LPCWSTR* ppwszAcceptTypes,
    649	                                       DWORD dwFlags);
    650
    651	WINPR_API BOOL WinHttpAddRequestHeaders(HINTERNET hRequest, LPCWSTR pwszHeaders,
    652	                                        DWORD dwHeadersLength, DWORD dwModifiers);
    653
    654	WINPR_API BOOL WinHttpSendRequest(HINTERNET hRequest, LPCWSTR lpszHeaders,
    655	                                  DWORD dwHeadersLength, LPVOID lpOptional,
    656	                                  DWORD dwOptionalLength, DWORD dwTotalLength,
    657	                                  DWORD_PTR dwContext);
    658
    659	WINPR_API BOOL WinHttpSetCredentials(HINTERNET hRequest, DWORD AuthTargets, DWORD AuthScheme,
    660	                                     LPCWSTR pwszUserName, LPCWSTR pwszPassword,
    661	                                     LPVOID pAuthParams);
    662
    663	WINPR_API BOOL WinHttpQueryAuthSchemes(HINTERNET hRequest, LPDWORD lpdwSupportedSchemes,
    664	                                       LPDWORD lpdwFirstScheme, LPDWORD pdwAuthTarget);
    665	WINPR_API BOOL WinHttpQueryAuthParams(HINTERNET hRequest, DWORD AuthScheme,
    666	                                      LPVOID* pAuthParams);
    667
    668	WINPR_API BOOL WinHttpReceiveResponse(HINTERNET hRequest, LPVOID lpReserved);
    669
    670	WINPR_API BOOL WinHttpQueryHeaders(HINTERNET hRequest, DWORD dwInfoLevel, LPCWSTR pwszName,
    671	                                   LPVOID lpBuffer, LPDWORD lpdwBufferLength,
    672	                                   LPDWORD lpdwIndex);
    673
    674	WINPR_API BOOL WinHttpDetectAutoProxyConfigUrl(DWORD dwAutoDetectFlags,
    675	                                               LPWSTR* ppwstrAutoConfigUrl);
    676
    677	WINPR_API BOOL WinHttpGetProxyForUrl(HINTERNET hSession, LPCWSTR lpcwszUrl,
    678	                                     WINHTTP_AUTOPROXY_OPTIONS* pAutoProxyOptions,
    679	                                     WINHTTP_PROXY_INFO* pProxyInfo);
    680
    681	WINPR_API BOOL
    682	WinHttpGetIEProxyConfigForCurrentUser(WINHTTP_CURRENT_USER_IE_PROXY_CONFIG* pProxyConfig);
    683
    684#ifdef __cplusplus
    685}
    686#endif
    687
    688#endif
    689
    690#endif /* WINPR_WINHTTP_H */