blob: 5c0719342f4496a489462d8beee77dbc02ca142e [file] [log] [blame]
Jens Geyer02230912019-04-03 01:12:51 +02001(*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 *)
19unit Thrift.WinHTTP;
20
21{$I Thrift.Defines.inc}
22{$SCOPEDENUMS ON}
23
24// packing according to winhttp.h
25{$IFDEF Win64} {$ALIGN 8} {$ELSE} {$ALIGN 4} {$ENDIF}
26
27interface
28
29uses
30 Windows,
31 Classes,
32 SysUtils,
33 Math,
34 Generics.Collections;
35
36
37type
38 HINTERNET = type Pointer;
39 INTERNET_PORT = type WORD;
40 INTERNET_SCHEME = type Integer;
41 LPLPCWSTR = ^LPCWSTR;
42
43 LPURL_COMPONENTS = ^URL_COMPONENTS;
44 URL_COMPONENTS = record
45 dwStructSize : DWORD; // set to SizeOf(URL_COMPONENTS)
46 lpszScheme : LPWSTR; // scheme name
47 dwSchemeLength : DWORD;
48 nScheme : INTERNET_SCHEME; // enumerated scheme type
49 lpszHostName : LPWSTR; // host name
50 dwHostNameLength : DWORD;
51 nPort : INTERNET_PORT; // port number
52 lpszUserName : LPWSTR; // user name
53 dwUserNameLength : DWORD;
54 lpszPassword : LPWSTR; // password
55 dwPasswordLength : DWORD;
56 lpszUrlPath : LPWSTR; // URL-path
57 dwUrlPathLength : DWORD;
58 lpszExtraInfo : LPWSTR; // extra information
59 dwExtraInfoLength : DWORD;
60 end;
61
62 URL_COMPONENTSW = URL_COMPONENTS;
63 LPURL_COMPONENTSW = LPURL_COMPONENTS;
64
65
Jens Geyer83ff7532019-06-06 22:46:03 +020066 // When retrieving proxy data, an application must free the lpszProxy and
67 // lpszProxyBypass strings contained in this structure (if they are non-NULL)
68 // using the GlobalFree function.
69 LPWINHTTP_PROXY_INFO = ^WINHTTP_PROXY_INFO;
70 WINHTTP_PROXY_INFO = record
71 dwAccessType : DWORD; // see WINHTTP_ACCESS_* types below
72 lpszProxy : LPWSTR; // proxy server list
73 lpszProxyBypass : LPWSTR; // proxy bypass list
74 end;
75
76 LPWINHTTP_PROXY_INFOW = ^WINHTTP_PROXY_INFOW;
77 WINHTTP_PROXY_INFOW = WINHTTP_PROXY_INFO;
78
79
80 WINHTTP_AUTOPROXY_OPTIONS = record
81 dwFlags : DWORD;
82 dwAutoDetectFlags : DWORD;
83 lpszAutoConfigUrl : LPCWSTR;
84 lpvReserved : LPVOID;
85 dwReserved : DWORD;
86 fAutoLogonIfChallenged : BOOL;
87 end;
88
89
90 WINHTTP_CURRENT_USER_IE_PROXY_CONFIG = record
91 fAutoDetect : BOOL;
92 lpszAutoConfigUrl : LPWSTR;
93 lpszProxy : LPWSTR;
94 lpszProxyBypass : LPWSTR;
95 end;
96
97
98
99
Jens Geyer02230912019-04-03 01:12:51 +0200100function WinHttpCloseHandle( aHandle : HINTERNET) : BOOL; stdcall;
101
102function WinHttpOpen( const pszAgentW : LPCWSTR;
103 const dwAccessType : DWORD;
104 const pszProxyW : LPCWSTR;
105 const pszProxyBypassW : LPCWSTR;
106 const dwFlags : DWORD
107 ) : HINTERNET; stdcall;
108
109function WinHttpConnect( const hSession : HINTERNET;
110 const pswzServerName : LPCWSTR;
111 const nServerPort : INTERNET_PORT;
112 const dwReserved : DWORD
113 ) : HINTERNET; stdcall;
114
115function WinHttpOpenRequest( const hConnect : HINTERNET;
116 const pwszVerb, pwszObjectName, pwszVersion, pwszReferrer : LPCWSTR;
117 const ppwszAcceptTypes : LPLPCWSTR;
118 const dwFlags : DWORD
119 ) : HINTERNET; stdcall;
120
Jens Geyer47f63172019-06-06 22:42:58 +0200121function WinHttpQueryOption( const hInternet : HINTERNET;
122 const dwOption : DWORD;
123 const pBuffer : Pointer;
124 var dwBufferLength : DWORD) : BOOL; stdcall;
125
126function WinHttpSetOption( const hInternet : HINTERNET;
127 const dwOption : DWORD;
128 const pBuffer : Pointer;
129 const dwBufferLength : DWORD) : BOOL; stdcall;
130
Jens Geyer02230912019-04-03 01:12:51 +0200131function WinHttpSetTimeouts( const hRequestOrSession : HINTERNET;
132 const aResolveTimeout, aConnectTimeout, aSendTimeout, aReceiveTimeout : Int32
133 ) : BOOL; stdcall;
134
135function WinHttpAddRequestHeaders( const hRequest : HINTERNET;
136 const pwszHeaders : LPCWSTR;
137 const dwHeadersLengthInChars : DWORD;
138 const dwModifiers : DWORD
139 ) : BOOL; stdcall;
140
Jens Geyer83ff7532019-06-06 22:46:03 +0200141function WinHttpGetProxyForUrl( const hSession : HINTERNET;
142 const lpcwszUrl : LPCWSTR;
143 const options : WINHTTP_AUTOPROXY_OPTIONS;
144 const info : WINHTTP_PROXY_INFO
145 ) : BOOL; stdcall;
146
147function WinHttpGetIEProxyConfigForCurrentUser( var config : WINHTTP_CURRENT_USER_IE_PROXY_CONFIG
148 ) : BOOL; stdcall;
149
150
Jens Geyer02230912019-04-03 01:12:51 +0200151function WinHttpSendRequest( const hRequest : HINTERNET;
152 const lpszHeaders : LPCWSTR;
153 const dwHeadersLength : DWORD;
154 const lpOptional : Pointer;
155 const dwOptionalLength : DWORD;
156 const dwTotalLength : DWORD;
157 const pContext : Pointer
158 ) : BOOL; stdcall;
159
160function WinHttpWriteData( const hRequest : HINTERNET;
161 const pBuf : Pointer;
162 const dwBytesToWrite : DWORD;
163 out dwBytesWritten : DWORD
164 ) : BOOL; stdcall;
165
166function WinHttpReceiveResponse( const hRequest : HINTERNET; const lpReserved : Pointer) : BOOL; stdcall;
167
168function WinHttpQueryHeaders( const hRequest : HINTERNET;
169 const dwInfoLevel : DWORD;
170 const pwszName : LPCWSTR;
171 const lpBuffer : Pointer;
172 var dwBufferLength : DWORD;
173 var dwIndex : DWORD
174 ) : BOOL; stdcall;
175
176function WinHttpQueryDataAvailable( const hRequest : HINTERNET;
177 var dwNumberOfBytesAvailable : DWORD
178 ) : BOOL; stdcall;
179
180function WinHttpReadData( const hRequest : HINTERNET;
181 const lpBuffer : Pointer;
182 const dwBytesToRead : DWORD;
183 out dwBytesRead : DWORD
184 ) : BOOL; stdcall;
185
186function WinHttpCrackUrl( const pwszUrl : LPCWSTR;
187 const dwUrlLength : DWORD;
188 const dwFlags : DWORD;
189 var urlComponents : URL_COMPONENTS
190 ) : BOOL; stdcall;
191
192function WinHttpCreateUrl( const UrlComponents : URL_COMPONENTS;
193 const dwFlags : DWORD;
194 const pwszUrl : LPCWSTR;
195 var pdwUrlLength : DWORD
196 ) : BOOL; stdcall;
197
198
199const
200 // WinHttpOpen dwAccessType values
201 WINHTTP_ACCESS_TYPE_DEFAULT_PROXY = 0;
202 WINHTTP_ACCESS_TYPE_NO_PROXY = 1;
203 WINHTTP_ACCESS_TYPE_NAMED_PROXY = 3;
204
205 // flags for WinHttpOpen():
206 WINHTTP_FLAG_ASYNC = $10000000; // want async session, requires WinHttpSetStatusCallback() usage
207
Jens Geyer528a0f02019-11-18 20:17:03 +0100208 WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH = 0;
209
Jens Geyer02230912019-04-03 01:12:51 +0200210 // ports
211 INTERNET_DEFAULT_PORT = 0; // use the protocol-specific default (80 or 443)
212
213 // flags for WinHttpOpenRequest():
214 WINHTTP_FLAG_SECURE = $00800000; // use SSL if applicable (HTTPS)
215 WINHTTP_FLAG_ESCAPE_PERCENT = $00000004; // if escaping enabled, escape percent as well
216 WINHTTP_FLAG_NULL_CODEPAGE = $00000008; // assume all symbols are ASCII, use fast convertion
217 WINHTTP_FLAG_BYPASS_PROXY_CACHE = $00000100; // add "pragma: no-cache" request header
218 WINHTTP_FLAG_REFRESH = WINHTTP_FLAG_BYPASS_PROXY_CACHE;
219 WINHTTP_FLAG_ESCAPE_DISABLE = $00000040; // disable escaping
220 WINHTTP_FLAG_ESCAPE_DISABLE_QUERY = $00000080; // if escaping enabled escape path part, but do not escape query
221
222 // flags for WinHttpSendRequest():
Jens Geyer528a0f02019-11-18 20:17:03 +0100223 WINHTTP_NO_PROXY_NAME = nil;
224 WINHTTP_NO_PROXY_BYPASS = nil;
225 WINHTTP_NO_CLIENT_CERT_CONTEXT = nil;
226 WINHTTP_NO_REFERER = nil;
227 WINHTTP_DEFAULT_ACCEPT_TYPES = nil;
Jens Geyer02230912019-04-03 01:12:51 +0200228 WINHTTP_NO_ADDITIONAL_HEADERS = nil;
229 WINHTTP_NO_REQUEST_DATA = nil;
Jens Geyer528a0f02019-11-18 20:17:03 +0100230 WINHTTP_HEADER_NAME_BY_INDEX = nil;
231 WINHTTP_NO_OUTPUT_BUFFER = nil;
232 WINHTTP_NO_HEADER_INDEX = nil;
Jens Geyer02230912019-04-03 01:12:51 +0200233
234 // WinHttpAddRequestHeaders() dwModifiers
235 WINHTTP_ADDREQ_INDEX_MASK = $0000FFFF;
236 WINHTTP_ADDREQ_FLAGS_MASK = $FFFF0000;
237
238 WINHTTP_ADDREQ_FLAG_ADD_IF_NEW = $10000000;
239 WINHTTP_ADDREQ_FLAG_ADD = $20000000;
240 WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA = $40000000;
241 WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON = $01000000;
242 WINHTTP_ADDREQ_FLAG_COALESCE = WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA;
243 WINHTTP_ADDREQ_FLAG_REPLACE = $80000000;
244
245 // URL functions
246 ICU_NO_ENCODE = $20000000; // Don't convert unsafe characters to escape sequence
247 ICU_DECODE = $10000000; // Convert %XX escape sequences to characters
248 ICU_NO_META = $08000000; // Don't convert .. etc. meta path sequences
249 ICU_ENCODE_SPACES_ONLY = $04000000; // Encode spaces only
250 ICU_BROWSER_MODE = $02000000; // Special encode/decode rules for browser
251 ICU_ENCODE_PERCENT = $00001000; // Encode any percent (ASCII25)
252
253 ICU_ESCAPE = $80000000; // (un)escape URL characters
254 ICU_ESCAPE_AUTHORITY = $00002000; // causes InternetCreateUrlA to escape chars in authority components (user, pwd, host)
255 ICU_REJECT_USERPWD = $00004000; // rejects usrls whick have username/pwd sections
256
257 INTERNET_SCHEME_HTTP = INTERNET_SCHEME(1);
258 INTERNET_SCHEME_HTTPS = INTERNET_SCHEME(2);
259
Jens Geyer47f63172019-06-06 22:42:58 +0200260 // options manifests for WinHttp{Query|Set}Option
261 WINHTTP_OPTION_CALLBACK = 1;
262 WINHTTP_OPTION_RESOLVE_TIMEOUT = 2;
263 WINHTTP_OPTION_CONNECT_TIMEOUT = 3;
264 WINHTTP_OPTION_CONNECT_RETRIES = 4;
265 WINHTTP_OPTION_SEND_TIMEOUT = 5;
266 WINHTTP_OPTION_RECEIVE_TIMEOUT = 6;
267 WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT = 7;
268 WINHTTP_OPTION_HANDLE_TYPE = 9;
269 WINHTTP_OPTION_READ_BUFFER_SIZE = 12;
270 WINHTTP_OPTION_WRITE_BUFFER_SIZE = 13;
271 WINHTTP_OPTION_PARENT_HANDLE = 21;
272 WINHTTP_OPTION_EXTENDED_ERROR = 24;
273 WINHTTP_OPTION_SECURITY_FLAGS = 31;
274 WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT = 32;
275 WINHTTP_OPTION_URL = 34;
276 WINHTTP_OPTION_SECURITY_KEY_BITNESS = 36;
277 WINHTTP_OPTION_PROXY = 38;
278 WINHTTP_OPTION_USER_AGENT = 41;
279 WINHTTP_OPTION_CONTEXT_VALUE = 45;
280 WINHTTP_OPTION_CLIENT_CERT_CONTEXT = 47;
281 WINHTTP_OPTION_REQUEST_PRIORITY = 58;
282 WINHTTP_OPTION_HTTP_VERSION = 59;
283 WINHTTP_OPTION_DISABLE_FEATURE = 63;
284 WINHTTP_OPTION_CODEPAGE = 68;
285 WINHTTP_OPTION_MAX_CONNS_PER_SERVER = 73;
286 WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER = 74;
287 WINHTTP_OPTION_AUTOLOGON_POLICY = 77;
288 WINHTTP_OPTION_SERVER_CERT_CONTEXT = 78;
289 WINHTTP_OPTION_ENABLE_FEATURE = 79;
290 WINHTTP_OPTION_WORKER_THREAD_COUNT = 80;
291 WINHTTP_OPTION_PASSPORT_COBRANDING_TEXT = 81;
292 WINHTTP_OPTION_PASSPORT_COBRANDING_URL = 82;
293 WINHTTP_OPTION_CONFIGURE_PASSPORT_AUTH = 83;
294 WINHTTP_OPTION_SECURE_PROTOCOLS = 84;
295 WINHTTP_OPTION_ENABLETRACING = 85;
296 WINHTTP_OPTION_PASSPORT_SIGN_OUT = 86;
297 WINHTTP_OPTION_PASSPORT_RETURN_URL = 87;
298 WINHTTP_OPTION_REDIRECT_POLICY = 88;
299 WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS = 89;
300 WINHTTP_OPTION_MAX_HTTP_STATUS_CONTINUE = 90;
301 WINHTTP_OPTION_MAX_RESPONSE_HEADER_SIZE = 91;
302 WINHTTP_OPTION_MAX_RESPONSE_DRAIN_SIZE = 92;
303 WINHTTP_OPTION_CONNECTION_INFO = 93;
304 WINHTTP_OPTION_CLIENT_CERT_ISSUER_LIST = 94;
305 WINHTTP_OPTION_SPN = 96;
306 WINHTTP_OPTION_GLOBAL_PROXY_CREDS = 97;
307 WINHTTP_OPTION_GLOBAL_SERVER_CREDS = 98;
308 WINHTTP_OPTION_UNLOAD_NOTIFY_EVENT = 99;
309 WINHTTP_OPTION_REJECT_USERPWD_IN_URL = 100;
310 WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS = 101;
311 WINHTTP_OPTION_RECEIVE_PROXY_CONNECT_RESPONSE = 103;
312 WINHTTP_OPTION_IS_PROXY_CONNECT_RESPONSE = 104;
313 WINHTTP_OPTION_SERVER_SPN_USED = 106;
314 WINHTTP_OPTION_PROXY_SPN_USED = 107;
315 WINHTTP_OPTION_SERVER_CBT = 108;
Jens Geyer19505c32019-06-22 00:59:54 +0200316 // options for newer WinHTTP versions
317 WINHTTP_OPTION_DECOMPRESSION = 118;
Jens Geyer47f63172019-06-06 22:42:58 +0200318 //
319 WINHTTP_FIRST_OPTION = WINHTTP_OPTION_CALLBACK;
Jens Geyer19505c32019-06-22 00:59:54 +0200320 //WINHTTP_LAST_OPTION = WINHTTP_OPTION_SERVER_CBT;
Jens Geyer47f63172019-06-06 22:42:58 +0200321
322 WINHTTP_OPTION_USERNAME = $1000;
323 WINHTTP_OPTION_PASSWORD = $1001;
324 WINHTTP_OPTION_PROXY_USERNAME = $1002;
325 WINHTTP_OPTION_PROXY_PASSWORD = $1003;
326
327 // manifest value for WINHTTP_OPTION_MAX_CONNS_PER_SERVER and WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER
328 WINHTTP_CONNS_PER_SERVER_UNLIMITED = $FFFFFFFF;
329
330 // values for WINHTTP_OPTION_AUTOLOGON_POLICY
331 WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM = 0;
332 WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW = 1;
333 WINHTTP_AUTOLOGON_SECURITY_LEVEL_HIGH = 2;
334
335 WINHTTP_AUTOLOGON_SECURITY_LEVEL_DEFAULT = WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM;
336
337 // values for WINHTTP_OPTION_REDIRECT_POLICY
338 WINHTTP_OPTION_REDIRECT_POLICY_NEVER = 0;
339 WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP = 1;
340 WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS = 2;
341
342 WINHTTP_OPTION_REDIRECT_POLICY_LAST = WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS;
343 WINHTTP_OPTION_REDIRECT_POLICY_DEFAULT = WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP;
344
345 WINHTTP_DISABLE_PASSPORT_AUTH = $00000000;
346 WINHTTP_ENABLE_PASSPORT_AUTH = $10000000;
347 WINHTTP_DISABLE_PASSPORT_KEYRING = $20000000;
348 WINHTTP_ENABLE_PASSPORT_KEYRING = $40000000;
349
350 // values for WINHTTP_OPTION_DISABLE_FEATURE
351 WINHTTP_DISABLE_COOKIES = $00000001;
352 WINHTTP_DISABLE_REDIRECTS = $00000002;
353 WINHTTP_DISABLE_AUTHENTICATION = $00000004;
354 WINHTTP_DISABLE_KEEP_ALIVE = $00000008;
355
356 // values for WINHTTP_OPTION_ENABLE_FEATURE
357 WINHTTP_ENABLE_SSL_REVOCATION = $00000001;
358 WINHTTP_ENABLE_SSL_REVERT_IMPERSONATION = $00000002;
359
360 // values for WINHTTP_OPTION_SPN
361 WINHTTP_DISABLE_SPN_SERVER_PORT = $00000000;
362 WINHTTP_ENABLE_SPN_SERVER_PORT = $00000001;
363 WINHTTP_OPTION_SPN_MASK = WINHTTP_ENABLE_SPN_SERVER_PORT;
364
365 // winhttp handle types
366 WINHTTP_HANDLE_TYPE_SESSION = 1;
367 WINHTTP_HANDLE_TYPE_CONNECT = 2;
368 WINHTTP_HANDLE_TYPE_REQUEST = 3;
369
370 // values for auth schemes
371 WINHTTP_AUTH_SCHEME_BASIC = $00000001;
372 WINHTTP_AUTH_SCHEME_NTLM = $00000002;
373 WINHTTP_AUTH_SCHEME_PASSPORT = $00000004;
374 WINHTTP_AUTH_SCHEME_DIGEST = $00000008;
375 WINHTTP_AUTH_SCHEME_NEGOTIATE = $00000010;
376
377 // WinHttp supported Authentication Targets
378 WINHTTP_AUTH_TARGET_SERVER = $00000000;
379 WINHTTP_AUTH_TARGET_PROXY = $00000001;
380
Jens Geyer19505c32019-06-22 00:59:54 +0200381 // options for WINHTTP_OPTION_DECOMPRESSION
382 WINHTTP_DECOMPRESSION_FLAG_GZIP = $00000001;
383 WINHTTP_DECOMPRESSION_FLAG_DEFLATE = $00000002;
384 WINHTTP_DECOMPRESSION_FLAG_ALL = WINHTTP_DECOMPRESSION_FLAG_GZIP
385 or WINHTTP_DECOMPRESSION_FLAG_DEFLATE;
386
Jens Geyer47f63172019-06-06 22:42:58 +0200387 // values for WINHTTP_OPTION_SECURITY_FLAGS
388
389 // query only
390 SECURITY_FLAG_SECURE = $00000001; // can query only
391 SECURITY_FLAG_STRENGTH_WEAK = $10000000;
392 SECURITY_FLAG_STRENGTH_MEDIUM = $40000000;
393 SECURITY_FLAG_STRENGTH_STRONG = $20000000;
394
Jens Geyer528a0f02019-11-18 20:17:03 +0100395 // query flags
396 WINHTTP_QUERY_MIME_VERSION = 0;
397 WINHTTP_QUERY_CONTENT_TYPE = 1;
398 WINHTTP_QUERY_CONTENT_TRANSFER_ENCODING = 2;
399 WINHTTP_QUERY_CONTENT_ID = 3;
400 WINHTTP_QUERY_CONTENT_DESCRIPTION = 4;
401 WINHTTP_QUERY_CONTENT_LENGTH = 5;
402 WINHTTP_QUERY_CONTENT_LANGUAGE = 6;
403 WINHTTP_QUERY_ALLOW = 7;
404 WINHTTP_QUERY_PUBLIC = 8;
405 WINHTTP_QUERY_DATE = 9;
406 WINHTTP_QUERY_EXPIRES = 10;
407 WINHTTP_QUERY_LAST_MODIFIED = 11;
408 WINHTTP_QUERY_MESSAGE_ID = 12;
409 WINHTTP_QUERY_URI = 13;
410 WINHTTP_QUERY_DERIVED_FROM = 14;
411 WINHTTP_QUERY_COST = 15;
412 WINHTTP_QUERY_LINK = 16;
413 WINHTTP_QUERY_PRAGMA = 17;
414 WINHTTP_QUERY_VERSION = 18;
415 WINHTTP_QUERY_STATUS_CODE = 19;
416 WINHTTP_QUERY_STATUS_TEXT = 20;
417 WINHTTP_QUERY_RAW_HEADERS = 21;
418 WINHTTP_QUERY_RAW_HEADERS_CRLF = 22;
419 WINHTTP_QUERY_CONNECTION = 23;
420 WINHTTP_QUERY_ACCEPT = 24;
421 WINHTTP_QUERY_ACCEPT_CHARSET = 25;
422 WINHTTP_QUERY_ACCEPT_ENCODING = 26;
423 WINHTTP_QUERY_ACCEPT_LANGUAGE = 27;
424 WINHTTP_QUERY_AUTHORIZATION = 28;
425 WINHTTP_QUERY_CONTENT_ENCODING = 29;
426 WINHTTP_QUERY_FORWARDED = 30;
427 WINHTTP_QUERY_FROM = 31;
428 WINHTTP_QUERY_IF_MODIFIED_SINCE = 32;
429 WINHTTP_QUERY_LOCATION = 33;
430 WINHTTP_QUERY_ORIG_URI = 34;
431 WINHTTP_QUERY_REFERER = 35;
432 WINHTTP_QUERY_RETRY_AFTER = 36;
433 WINHTTP_QUERY_SERVER = 37;
434 WINHTTP_QUERY_TITLE = 38;
435 WINHTTP_QUERY_USER_AGENT = 39;
436 WINHTTP_QUERY_WWW_AUTHENTICATE = 40;
437 WINHTTP_QUERY_PROXY_AUTHENTICATE = 41;
438 WINHTTP_QUERY_ACCEPT_RANGES = 42;
439 WINHTTP_QUERY_SET_COOKIE = 43;
440 WINHTTP_QUERY_COOKIE = 44;
441 WINHTTP_QUERY_REQUEST_METHOD = 45;
442 WINHTTP_QUERY_REFRESH = 46;
443 WINHTTP_QUERY_CONTENT_DISPOSITION = 47;
444 WINHTTP_QUERY_AGE = 48;
445 WINHTTP_QUERY_CACHE_CONTROL = 49;
446 WINHTTP_QUERY_CONTENT_BASE = 50;
447 WINHTTP_QUERY_CONTENT_LOCATION = 51;
448 WINHTTP_QUERY_CONTENT_MD5 = 52;
449 WINHTTP_QUERY_CONTENT_RANGE = 53;
450 WINHTTP_QUERY_ETAG = 54;
451 WINHTTP_QUERY_HOST = 55;
452 WINHTTP_QUERY_IF_MATCH = 56;
453 WINHTTP_QUERY_IF_NONE_MATCH = 57;
454 WINHTTP_QUERY_IF_RANGE = 58;
455 WINHTTP_QUERY_IF_UNMODIFIED_SINCE = 59;
456 WINHTTP_QUERY_MAX_FORWARDS = 60;
457 WINHTTP_QUERY_PROXY_AUTHORIZATION = 61;
458 WINHTTP_QUERY_RANGE = 62;
459 WINHTTP_QUERY_TRANSFER_ENCODING = 63;
460 WINHTTP_QUERY_UPGRADE = 64;
461 WINHTTP_QUERY_VARY = 65;
462 WINHTTP_QUERY_VIA = 66;
463 WINHTTP_QUERY_WARNING = 67;
464 WINHTTP_QUERY_EXPECT = 68;
465 WINHTTP_QUERY_PROXY_CONNECTION = 69;
466 WINHTTP_QUERY_UNLESS_MODIFIED_SINCE = 70;
467 WINHTTP_QUERY_PROXY_SUPPORT = 75;
468 WINHTTP_QUERY_AUTHENTICATION_INFO = 76;
469 WINHTTP_QUERY_PASSPORT_URLS = 77;
470 WINHTTP_QUERY_PASSPORT_CONFIG = 78;
471 WINHTTP_QUERY_MAX = 78;
472 WINHTTP_QUERY_CUSTOM = 65535;
473 WINHTTP_QUERY_FLAG_REQUEST_HEADERS = $80000000;
474 WINHTTP_QUERY_FLAG_SYSTEMTIME = $40000000;
475 WINHTTP_QUERY_FLAG_NUMBER = $20000000;
476
Jens Geyer47f63172019-06-06 22:42:58 +0200477 // Secure connection error status flags
478 WINHTTP_CALLBACK_STATUS_FLAG_CERT_REV_FAILED = $00000001;
479 WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CERT = $00000002;
480 WINHTTP_CALLBACK_STATUS_FLAG_CERT_REVOKED = $00000004;
481 WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CA = $00000008;
482 WINHTTP_CALLBACK_STATUS_FLAG_CERT_CN_INVALID = $00000010;
483 WINHTTP_CALLBACK_STATUS_FLAG_CERT_DATE_INVALID = $00000020;
484 WINHTTP_CALLBACK_STATUS_FLAG_CERT_WRONG_USAGE = $00000040;
485 WINHTTP_CALLBACK_STATUS_FLAG_SECURITY_CHANNEL_ERROR = $80000000;
486
487 WINHTTP_FLAG_SECURE_PROTOCOL_SSL2 = $00000008;
488 WINHTTP_FLAG_SECURE_PROTOCOL_SSL3 = $00000020;
489 WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 = $00000080;
490 WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 = $00000200;
491 WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2 = $00000800;
492
493 // Note: SECURE_PROTOCOL_ALL does not include TLS1.1 and higher!
494 WINHTTP_FLAG_SECURE_PROTOCOL_ALL = WINHTTP_FLAG_SECURE_PROTOCOL_SSL2
495 or WINHTTP_FLAG_SECURE_PROTOCOL_SSL3
496 or WINHTTP_FLAG_SECURE_PROTOCOL_TLS1;
497
Jens Geyer83ff7532019-06-06 22:46:03 +0200498 // AutoProxy
499 WINHTTP_AUTOPROXY_AUTO_DETECT = $00000001;
500 WINHTTP_AUTOPROXY_CONFIG_URL = $00000002;
501 WINHTTP_AUTOPROXY_HOST_KEEPCASE = $00000004;
502 WINHTTP_AUTOPROXY_HOST_LOWERCASE = $00000008;
503 WINHTTP_AUTOPROXY_RUN_INPROCESS = $00010000;
504 WINHTTP_AUTOPROXY_RUN_OUTPROCESS_ONLY = $00020000;
505
506 // Flags for dwAutoDetectFlags
507 WINHTTP_AUTO_DETECT_TYPE_DHCP = $00000001;
508 WINHTTP_AUTO_DETECT_TYPE_DNS_A = $00000002;
Jens Geyer47f63172019-06-06 22:42:58 +0200509
Jens Geyer02230912019-04-03 01:12:51 +0200510const
511 WINHTTP_ERROR_BASE = 12000;
512 ERROR_WINHTTP_OUT_OF_HANDLES = WINHTTP_ERROR_BASE + 1;
513 ERROR_WINHTTP_TIMEOUT = WINHTTP_ERROR_BASE + 2;
514 ERROR_WINHTTP_INTERNAL_ERROR = WINHTTP_ERROR_BASE + 4;
515 ERROR_WINHTTP_INVALID_URL = WINHTTP_ERROR_BASE + 5;
516 ERROR_WINHTTP_UNRECOGNIZED_SCHEME = WINHTTP_ERROR_BASE + 6;
517 ERROR_WINHTTP_NAME_NOT_RESOLVED = WINHTTP_ERROR_BASE + 7;
518 ERROR_WINHTTP_INVALID_OPTION = WINHTTP_ERROR_BASE + 9;
519 ERROR_WINHTTP_OPTION_NOT_SETTABLE = WINHTTP_ERROR_BASE + 11;
520 ERROR_WINHTTP_SHUTDOWN = WINHTTP_ERROR_BASE + 12;
521 ERROR_WINHTTP_LOGIN_FAILURE = WINHTTP_ERROR_BASE + 15;
522 ERROR_WINHTTP_OPERATION_CANCELLED = WINHTTP_ERROR_BASE + 17;
523 ERROR_WINHTTP_INCORRECT_HANDLE_TYPE = WINHTTP_ERROR_BASE + 18;
524 ERROR_WINHTTP_INCORRECT_HANDLE_STATE = WINHTTP_ERROR_BASE + 19;
525 ERROR_WINHTTP_CANNOT_CONNECT = WINHTTP_ERROR_BASE + 29;
526 ERROR_WINHTTP_CONNECTION_ERROR = WINHTTP_ERROR_BASE + 30;
527 ERROR_WINHTTP_RESEND_REQUEST = WINHTTP_ERROR_BASE + 32;
528 ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED = WINHTTP_ERROR_BASE + 44;
529 ERROR_WINHTTP_CANNOT_CALL_BEFORE_OPEN = WINHTTP_ERROR_BASE + 100;
530 ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND = WINHTTP_ERROR_BASE + 101;
531 ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND = WINHTTP_ERROR_BASE + 102;
532 ERROR_WINHTTP_CANNOT_CALL_AFTER_OPEN = WINHTTP_ERROR_BASE + 103;
533 ERROR_WINHTTP_HEADER_NOT_FOUND = WINHTTP_ERROR_BASE + 150;
534 ERROR_WINHTTP_INVALID_SERVER_RESPONSE = WINHTTP_ERROR_BASE + 152;
535 ERROR_WINHTTP_INVALID_HEADER = WINHTTP_ERROR_BASE + 153;
536 ERROR_WINHTTP_INVALID_QUERY_REQUEST = WINHTTP_ERROR_BASE + 154;
537 ERROR_WINHTTP_HEADER_ALREADY_EXISTS = WINHTTP_ERROR_BASE + 155;
538 ERROR_WINHTTP_REDIRECT_FAILED = WINHTTP_ERROR_BASE + 156;
539 ERROR_WINHTTP_AUTO_PROXY_SERVICE_ERROR = WINHTTP_ERROR_BASE + 178;
540 ERROR_WINHTTP_BAD_AUTO_PROXY_SCRIPT = WINHTTP_ERROR_BASE + 166;
541 ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT = WINHTTP_ERROR_BASE + 167;
542 ERROR_WINHTTP_NOT_INITIALIZED = WINHTTP_ERROR_BASE + 172;
543 ERROR_WINHTTP_SECURE_FAILURE = WINHTTP_ERROR_BASE + 175;
544
545 // Certificate security errors. Additional information is provided
546 // via the WINHTTP_CALLBACK_STATUS_SECURE_FAILURE callback notification.
547 ERROR_WINHTTP_SECURE_CERT_DATE_INVALID = WINHTTP_ERROR_BASE + 37;
548 ERROR_WINHTTP_SECURE_CERT_CN_INVALID = WINHTTP_ERROR_BASE + 38;
549 ERROR_WINHTTP_SECURE_INVALID_CA = WINHTTP_ERROR_BASE + 45;
550 ERROR_WINHTTP_SECURE_CERT_REV_FAILED = WINHTTP_ERROR_BASE + 57;
551 ERROR_WINHTTP_SECURE_CHANNEL_ERROR = WINHTTP_ERROR_BASE + 157;
552 ERROR_WINHTTP_SECURE_INVALID_CERT = WINHTTP_ERROR_BASE + 169;
553 ERROR_WINHTTP_SECURE_CERT_REVOKED = WINHTTP_ERROR_BASE + 170;
554 ERROR_WINHTTP_SECURE_CERT_WRONG_USAGE = WINHTTP_ERROR_BASE + 179;
555
556 ERROR_WINHTTP_AUTODETECTION_FAILED = WINHTTP_ERROR_BASE + 180;
557 ERROR_WINHTTP_HEADER_COUNT_EXCEEDED = WINHTTP_ERROR_BASE + 181;
558 ERROR_WINHTTP_HEADER_SIZE_OVERFLOW = WINHTTP_ERROR_BASE + 182;
559 ERROR_WINHTTP_CHUNKED_ENCODING_HEADER_SIZE_OVERFLOW = WINHTTP_ERROR_BASE + 183;
560 ERROR_WINHTTP_RESPONSE_DRAIN_OVERFLOW = WINHTTP_ERROR_BASE + 184;
561 ERROR_WINHTTP_CLIENT_CERT_NO_PRIVATE_KEY = WINHTTP_ERROR_BASE + 185;
562 ERROR_WINHTTP_CLIENT_CERT_NO_ACCESS_PRIVATE_KEY = WINHTTP_ERROR_BASE + 186;
563
Jens Geyer433a6492019-06-19 23:14:08 +0200564 WINHTTP_ERROR_LAST = WINHTTP_ERROR_BASE + 186;
565
Jens Geyer02230912019-04-03 01:12:51 +0200566
567const
568 WINHTTP_THRIFT_DEFAULTS = WINHTTP_FLAG_NULL_CODEPAGE
569 or WINHTTP_FLAG_BYPASS_PROXY_CACHE
570 or WINHTTP_FLAG_ESCAPE_DISABLE;
571
572
Jens Geyer47f63172019-06-06 22:42:58 +0200573
Jens Geyer02230912019-04-03 01:12:51 +0200574type
Jens Geyer83ff7532019-06-06 22:46:03 +0200575 IWinHTTPSession = interface;
576 IWinHTTPConnection = interface;
577
Jens Geyer02230912019-04-03 01:12:51 +0200578 IWinHTTPRequest = interface
Jens Geyerb0123182020-02-12 12:16:19 +0100579 ['{7AE6F63F-49B6-436B-8AAB-159E58EB900A}']
Jens Geyer02230912019-04-03 01:12:51 +0200580 function Handle : HINTERNET;
Jens Geyer83ff7532019-06-06 22:46:03 +0200581 function Connection : IWinHTTPConnection;
Jens Geyer02230912019-04-03 01:12:51 +0200582 function AddRequestHeader( const aHeader : string; const addflag : DWORD = WINHTTP_ADDREQ_FLAG_ADD) : Boolean;
583 function SetTimeouts( const aResolveTimeout, aConnectTimeout, aSendTimeout, aReceiveTimeout : Int32) : Boolean;
Jens Geyer83ff7532019-06-06 22:46:03 +0200584 procedure TryAutoProxy( const aUrl : string);
Jens Geyer19505c32019-06-22 00:59:54 +0200585 procedure EnableAutomaticContentDecompression( const aEnable : Boolean);
Jens Geyer02230912019-04-03 01:12:51 +0200586 function SendRequest( const pBuf : Pointer; const dwBytes : DWORD; const dwExtra : DWORD = 0) : Boolean;
587 function WriteExtraData( const pBuf : Pointer; const dwBytes : DWORD) : DWORD;
588 function FlushAndReceiveResponse : Boolean;
589 function ReadData( const dwRead : DWORD) : TBytes; overload;
590 function ReadData( const pBuf : Pointer; const dwRead : DWORD) : DWORD; overload;
Jens Geyer41f47af2019-11-09 23:24:52 +0100591 function QueryDataAvailable : DWORD;
Jens Geyerb0123182020-02-12 12:16:19 +0100592 function QueryTotalResponseSize( out dwSize : DWORD) : Boolean;
Jens Geyer02230912019-04-03 01:12:51 +0200593 end;
594
595 IWinHTTPConnection = interface
Jens Geyer83ff7532019-06-06 22:46:03 +0200596 ['{ED5BCA49-84D6-4CFE-BF18-3238B1FF2AFB}']
Jens Geyer02230912019-04-03 01:12:51 +0200597 function Handle : HINTERNET;
Jens Geyer83ff7532019-06-06 22:46:03 +0200598 function Session : IWinHTTPSession;
Jens Geyer02230912019-04-03 01:12:51 +0200599 function OpenRequest( const secure : Boolean; const aVerb, aObjName, aAcceptTypes : UnicodeString) : IWinHTTPRequest;
600 end;
601
602 IWinHTTPSession = interface
Jens Geyer47f63172019-06-06 22:42:58 +0200603 ['{261ADCB7-5465-4407-8840-468C17F009F0}']
Jens Geyer02230912019-04-03 01:12:51 +0200604 function Handle : HINTERNET;
605 function Connect( const aHostName : UnicodeString; const aPort : INTERNET_PORT = INTERNET_DEFAULT_PORT) : IWinHTTPConnection;
606 function SetTimeouts( const aResolveTimeout, aConnectTimeout, aSendTimeout, aReceiveTimeout : Int32) : Boolean;
Jens Geyer47f63172019-06-06 22:42:58 +0200607 function EnableSecureProtocols( const aFlagSet : DWORD) : Boolean;
Jens Geyer02230912019-04-03 01:12:51 +0200608 end;
609
610 IWinHTTPUrl = interface
611 ['{78BE977C-4171-4AF5-A250-FD2890205E63}']
612 // url parts getter
613 function GetScheme : UnicodeString;
614 function GetNumScheme : INTERNET_SCHEME;
615 function GetHostName : UnicodeString;
616 function GetPort : INTERNET_PORT;
617 function GetUserName : UnicodeString;
618 function GetPassword : UnicodeString;
619 function GetUrlPath : UnicodeString;
620 function GetExtraInfo : UnicodeString;
621
622 // url parts setter
623 procedure SetScheme( const value : UnicodeString);
624 procedure SetHostName ( const value : UnicodeString);
625 procedure SetPort( const value : INTERNET_PORT);
626 procedure SetUserName( const value : UnicodeString);
627 procedure SetPassword( const value : UnicodeString);
628 procedure SetUrlPath( const value : UnicodeString);
629 procedure SetExtraInfo( const value : UnicodeString);
630
631 // url as a whole
632 function BuildUrl : UnicodeString;
633 procedure CrackUrl( const value : UnicodeString);
634
635 // url parts
636 property Scheme : UnicodeString read GetScheme write SetScheme;
637 property NumScheme : INTERNET_SCHEME read GetNumScheme; // readonly
638 property HostName : UnicodeString read GetHostName write SetHostName;
639 property Port : INTERNET_PORT read GetPort write SetPort;
640 property UserName : UnicodeString read GetUserName write SetUserName;
641 property Password : UnicodeString read GetPassword write SetPassword;
642 property UrlPath : UnicodeString read GetUrlPath write SetUrlPath;
643 property ExtraInfo : UnicodeString read GetExtraInfo write SetExtraInfo;
644
645 // url as a whole
646 property CompleteURL : UnicodeString read BuildUrl write CrackUrl;
647 end;
648
649
650
651
652type
653 TWinHTTPHandleObjectImpl = class( TInterfacedObject)
654 strict protected
655 FHandle : HINTERNET;
656 function Handle : HINTERNET;
657 public
658 constructor Create( const aHandle : HINTERNET);
659 destructor Destroy; override;
660 end;
661
662
663 TWinHTTPSessionImpl = class( TWinHTTPHandleObjectImpl, IWinHTTPSession)
664 strict protected
665
666 // IWinHTTPSession
667 function Connect( const aHostName : UnicodeString; const aPort : INTERNET_PORT = INTERNET_DEFAULT_PORT) : IWinHTTPConnection;
668 function SetTimeouts( const aResolveTimeout, aConnectTimeout, aSendTimeout, aReceiveTimeout : Int32) : Boolean;
Jens Geyer47f63172019-06-06 22:42:58 +0200669 function EnableSecureProtocols( const aFlagSet : DWORD) : Boolean;
Jens Geyer02230912019-04-03 01:12:51 +0200670 public
671 constructor Create( const aAgent : UnicodeString;
672 const aAccessType : DWORD = WINHTTP_ACCESS_TYPE_DEFAULT_PROXY;
673 const aProxy : UnicodeString = '';
674 const aProxyBypass : UnicodeString = '';
675 const aFlags : DWORD = 0);
676 destructor Destroy; override;
677 end;
678
679
680 TWinHTTPConnectionImpl = class( TWinHTTPHandleObjectImpl, IWinHTTPConnection)
681 strict protected
682 FSession : IWinHTTPSession;
683
684 // IWinHTTPConnection
685 function OpenRequest( const secure : Boolean; const aVerb, aObjName, aAcceptTypes : UnicodeString) : IWinHTTPRequest;
Jens Geyer83ff7532019-06-06 22:46:03 +0200686 function Session : IWinHTTPSession;
Jens Geyer02230912019-04-03 01:12:51 +0200687
688 public
689 constructor Create( const aSession : IWinHTTPSession; const aHostName : UnicodeString; const aPort : INTERNET_PORT);
690 destructor Destroy; override;
691 end;
692
693
694 TAcceptTypesArray = array of string;
695
696 TWinHTTPRequestImpl = class( TWinHTTPHandleObjectImpl, IWinHTTPRequest)
697 strict protected
698 FConnection : IWinHTTPConnection;
699
700 // IWinHTTPRequest
Jens Geyer83ff7532019-06-06 22:46:03 +0200701 function Connection : IWinHTTPConnection;
Jens Geyer02230912019-04-03 01:12:51 +0200702 function AddRequestHeader( const aHeader : string; const addflag : DWORD = WINHTTP_ADDREQ_FLAG_ADD) : Boolean;
703 function SetTimeouts( const aResolveTimeout, aConnectTimeout, aSendTimeout, aReceiveTimeout : Int32) : Boolean;
Jens Geyer83ff7532019-06-06 22:46:03 +0200704 procedure TryAutoProxy( const aUrl : string);
Jens Geyer19505c32019-06-22 00:59:54 +0200705 procedure EnableAutomaticContentDecompression( const aEnable : Boolean);
Jens Geyer02230912019-04-03 01:12:51 +0200706 function SendRequest( const pBuf : Pointer; const dwBytes : DWORD; const dwExtra : DWORD = 0) : Boolean;
707 function WriteExtraData( const pBuf : Pointer; const dwBytes : DWORD) : DWORD;
708 function FlushAndReceiveResponse : Boolean;
709 function ReadData( const dwRead : DWORD) : TBytes; overload;
710 function ReadData( const pBuf : Pointer; const dwRead : DWORD) : DWORD; overload;
Jens Geyer41f47af2019-11-09 23:24:52 +0100711 function QueryDataAvailable : DWORD;
Jens Geyerb0123182020-02-12 12:16:19 +0100712 function QueryTotalResponseSize( out dwSize : DWORD) : Boolean;
Jens Geyer02230912019-04-03 01:12:51 +0200713
714 public
715 constructor Create( const aConnection : IWinHTTPConnection;
716 const aVerb, aObjName : UnicodeString;
717 const aVersion : UnicodeString = '';
718 const aReferrer : UnicodeString = '';
719 const aAcceptTypes : UnicodeString = '*/*';
720 const aFlags : DWORD = WINHTTP_THRIFT_DEFAULTS
721 );
722
723 destructor Destroy; override;
724 end;
725
726
727 TWinHTTPUrlImpl = class( TInterfacedObject, IWinHTTPUrl)
728 strict private
729 FScheme : UnicodeString;
730 FNumScheme : INTERNET_SCHEME;
731 FHostName : UnicodeString;
732 FPort : INTERNET_PORT;
733 FUserName : UnicodeString;
734 FPassword : UnicodeString;
735 FUrlPath : UnicodeString;
736 FExtraInfo : UnicodeString;
737
738 strict protected
739 // url parts getter
740 function GetScheme : UnicodeString;
741 function GetNumScheme : INTERNET_SCHEME;
742 function GetHostName : UnicodeString;
743 function GetPort : INTERNET_PORT;
744 function GetUserName : UnicodeString;
745 function GetPassword : UnicodeString;
746 function GetUrlPath : UnicodeString;
747 function GetExtraInfo : UnicodeString;
748
749 // url parts setter
750 procedure SetScheme( const value : UnicodeString);
751 procedure SetHostName ( const value : UnicodeString);
752 procedure SetPort( const value : INTERNET_PORT);
753 procedure SetUserName( const value : UnicodeString);
754 procedure SetPassword( const value : UnicodeString);
755 procedure SetUrlPath( const value : UnicodeString);
756 procedure SetExtraInfo( const value : UnicodeString);
757
758 // url as a whole
759 function BuildUrl : UnicodeString;
760 procedure CrackUrl( const value : UnicodeString);
761
762 public
763 constructor Create( const aUri : UnicodeString);
764 destructor Destroy; override;
765 end;
766
767
Jens Geyer83ff7532019-06-06 22:46:03 +0200768 WINHTTP_PROXY_INFO_Helper = record helper for WINHTTP_PROXY_INFO
769 procedure Initialize;
770 procedure FreeAllocatedResources;
771 end;
772
773
774 WINHTTP_CURRENT_USER_IE_PROXY_CONFIG_Helper = record helper for WINHTTP_CURRENT_USER_IE_PROXY_CONFIG
775 procedure Initialize;
776 procedure FreeAllocatedResources;
777 end;
778
779
Jens Geyer02230912019-04-03 01:12:51 +0200780 EWinHTTPException = class(Exception);
781
Jens Geyer433a6492019-06-19 23:14:08 +0200782{ helper functions }
783
784function WinHttpSysErrorMessage( const error : Cardinal): string;
785procedure RaiseLastWinHttpError;
786
787
Jens Geyer02230912019-04-03 01:12:51 +0200788implementation
789
790const WINHTTP_DLL = 'WinHTTP.dll';
791
792function WinHttpCloseHandle; stdcall; external WINHTTP_DLL;
793function WinHttpOpen; stdcall; external WINHTTP_DLL;
794function WinHttpConnect; stdcall; external WINHTTP_DLL;
795function WinHttpOpenRequest; stdcall; external WINHTTP_DLL;
796function WinHttpSendRequest; stdcall; external WINHTTP_DLL;
797function WinHttpSetTimeouts; stdcall; external WINHTTP_DLL;
Jens Geyer47f63172019-06-06 22:42:58 +0200798function WinHttpQueryOption; stdcall; external WINHTTP_DLL;
799function WinHttpSetOption; stdcall; external WINHTTP_DLL;
Jens Geyer02230912019-04-03 01:12:51 +0200800function WinHttpAddRequestHeaders; stdcall; external WINHTTP_DLL;
Jens Geyer83ff7532019-06-06 22:46:03 +0200801function WinHttpGetProxyForUrl; stdcall; external WINHTTP_DLL;
802function WinHttpGetIEProxyConfigForCurrentUser; stdcall; external WINHTTP_DLL;
Jens Geyer02230912019-04-03 01:12:51 +0200803function WinHttpWriteData; stdcall; external WINHTTP_DLL;
804function WinHttpReceiveResponse; stdcall; external WINHTTP_DLL;
805function WinHttpQueryHeaders; stdcall; external WINHTTP_DLL;
806function WinHttpQueryDataAvailable; stdcall; external WINHTTP_DLL;
807function WinHttpReadData; stdcall; external WINHTTP_DLL;
808function WinHttpCrackUrl; stdcall; external WINHTTP_DLL;
809function WinHttpCreateUrl; stdcall; external WINHTTP_DLL;
810
811
Jens Geyer433a6492019-06-19 23:14:08 +0200812{ helper functions }
813
814function WinHttpSysErrorMessage( const error : Cardinal): string;
815const FLAGS = FORMAT_MESSAGE_ALLOCATE_BUFFER
816 or FORMAT_MESSAGE_IGNORE_INSERTS
817 or FORMAT_MESSAGE_FROM_SYSTEM
818 or FORMAT_MESSAGE_FROM_HMODULE;
819var pBuffer : PChar;
820 nChars : Cardinal;
821begin
822 if (error < WINHTTP_ERROR_BASE)
823 or (error > WINHTTP_ERROR_LAST)
824 then Exit( SysUtils.SysErrorMessage( error));
825
826 pBuffer := nil;
827 try
828 nChars := FormatMessage( FLAGS,
829 Pointer( GetModuleHandle( WINHTTP_DLL)),
830 error,
831 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language
832 @pBuffer, 0,
833 nil);
834 SetString( result, pBuffer, nChars);
835 finally
Jens Geyer62238d12019-06-26 20:51:26 +0200836 LocalFree( NativeUInt( pBuffer));
Jens Geyer433a6492019-06-19 23:14:08 +0200837 end;
838end;
839
840
841procedure RaiseLastWinHttpError;
842var error : Cardinal;
843 sMsg : string;
844begin
845 error := Cardinal( GetLastError);
846 if error <> NOERROR then begin
847 sMSg := IntToStr(Integer(error))+' '+WinHttpSysErrorMessage(error);
848 raise EWinHTTPException.Create( sMsg);
849 end;
850end;
851
852
853
Jens Geyer83ff7532019-06-06 22:46:03 +0200854{ misc. record helper }
855
856
857procedure GlobalFreeAndNil( var p : LPWSTR);
858begin
859 if p <> nil then begin
860 GlobalFree( HGLOBAL( p));
861 p := nil;
862 end;
863end;
864
865
866procedure WINHTTP_PROXY_INFO_Helper.Initialize;
867begin
868 FillChar( Self, SizeOf(Self), 0);
869end;
870
871
872procedure WINHTTP_PROXY_INFO_Helper.FreeAllocatedResources;
873// The caller must free the lpszProxy and lpszProxyBypass strings
874// if they are non-NULL. Use GlobalFree to free the strings.
875begin
876 GlobalFreeAndNil( lpszProxy);
877 GlobalFreeAndNil( lpszProxyBypass);
878 Initialize;
879end;
880
881
882procedure WINHTTP_CURRENT_USER_IE_PROXY_CONFIG_Helper.Initialize;
883begin
884 FillChar( Self, SizeOf(Self), 0);
885end;
886
887
888procedure WINHTTP_CURRENT_USER_IE_PROXY_CONFIG_Helper.FreeAllocatedResources;
889// The caller must free the lpszProxy, lpszProxyBypass and lpszAutoConfigUrl strings
890// if they are non-NULL. Use GlobalFree to free the strings.
891begin
892 GlobalFreeAndNil( lpszProxy);
893 GlobalFreeAndNil( lpszProxyBypass);
894 GlobalFreeAndNil( lpszAutoConfigUrl);
895 Initialize;
896end;
897
898
Jens Geyer02230912019-04-03 01:12:51 +0200899{ TWinHTTPHandleObjectImpl }
900
901constructor TWinHTTPHandleObjectImpl.Create( const aHandle : HINTERNET);
902begin
903 inherited Create;
904 FHandle := aHandle;
905
906 if FHandle = nil
907 then raise EWinHTTPException.Create('Invalid handle');
908end;
909
910
911destructor TWinHTTPHandleObjectImpl.Destroy;
912begin
913 try
914 if Assigned(FHandle) then begin
915 WinHttpCloseHandle(FHandle);
916 FHandle := nil;
917 end;
918
919 finally
920 inherited Destroy;
921 end;
922end;
923
924
925function TWinHTTPHandleObjectImpl.Handle : HINTERNET;
926begin
927 result := FHandle;
928end;
929
930
931{ TWinHTTPSessionImpl }
932
933
934constructor TWinHTTPSessionImpl.Create( const aAgent : UnicodeString; const aAccessType : DWORD;
935 const aProxy, aProxyBypass : UnicodeString; const aFlags : DWORD);
936var handle : HINTERNET;
937begin
938 handle := WinHttpOpen( PWideChar(aAgent), aAccessType,
939 PWideChar(Pointer(aProxy)), // may be nil
940 PWideChar(Pointer(aProxyBypass)), // may be nil
941 aFlags);
Jens Geyer433a6492019-06-19 23:14:08 +0200942 if handle = nil then RaiseLastWinHttpError;
Jens Geyer02230912019-04-03 01:12:51 +0200943 inherited Create( handle);
944end;
945
946
947destructor TWinHTTPSessionImpl.Destroy;
948begin
949 inherited Destroy;
950 // add code here
951end;
952
953
954function TWinHTTPSessionImpl.Connect( const aHostName : UnicodeString; const aPort : INTERNET_PORT) : IWinHTTPConnection;
955begin
956 result := TWinHTTPConnectionImpl.Create( Self, aHostName, aPort);
957end;
958
959
960function TWinHTTPSessionImpl.SetTimeouts( const aResolveTimeout, aConnectTimeout, aSendTimeout, aReceiveTimeout : Int32) : Boolean;
961begin
962 result := WinHttpSetTimeouts( FHandle, aResolveTimeout, aConnectTimeout, aSendTimeout, aReceiveTimeout);
963end;
964
965
Jens Geyer47f63172019-06-06 22:42:58 +0200966function TWinHTTPSessionImpl.EnableSecureProtocols( const aFlagSet : DWORD) : Boolean;
967var dwSize : DWORD;
968begin
969 dwSize := SizeOf(aFlagSet);
970 result := WinHttpSetOption( Handle, WINHTTP_OPTION_SECURE_PROTOCOLS, @aFlagset, dwSize);
971end;
972
973
Jens Geyer02230912019-04-03 01:12:51 +0200974{ TWinHTTPConnectionImpl }
975
976constructor TWinHTTPConnectionImpl.Create( const aSession : IWinHTTPSession; const aHostName : UnicodeString; const aPort : INTERNET_PORT);
977var handle : HINTERNET;
978begin
979 FSession := aSession;
980 handle := WinHttpConnect( FSession.Handle, PWideChar(aHostName), aPort, 0);
Jens Geyer433a6492019-06-19 23:14:08 +0200981 if handle = nil then RaiseLastWinHttpError;
Jens Geyer02230912019-04-03 01:12:51 +0200982 inherited Create( handle);
983end;
984
985
986destructor TWinHTTPConnectionImpl.Destroy;
987begin
988 inherited Destroy;
989 FSession := nil;
990end;
991
992
Jens Geyer83ff7532019-06-06 22:46:03 +0200993function TWinHTTPConnectionImpl.Session : IWinHTTPSession;
994begin
995 result := FSession;
996end;
997
998
Jens Geyer02230912019-04-03 01:12:51 +0200999function TWinHTTPConnectionImpl.OpenRequest( const secure : Boolean; const aVerb, aObjName, aAcceptTypes : UnicodeString) : IWinHTTPRequest;
1000var dwFlags : DWORD;
1001begin
1002 dwFlags := WINHTTP_THRIFT_DEFAULTS;
1003 if secure
1004 then dwFlags := dwFlags or WINHTTP_FLAG_SECURE
1005 else dwFlags := dwFlags and not WINHTTP_FLAG_SECURE;
1006
1007 result := TWinHTTPRequestImpl.Create( Self, aVerb, aObjName, '', '', aAcceptTypes, dwFlags);
1008end;
1009
1010
1011{ TWinHTTPRequestImpl }
1012
1013constructor TWinHTTPRequestImpl.Create( const aConnection : IWinHTTPConnection;
1014 const aVerb, aObjName, aVersion, aReferrer : UnicodeString;
1015 const aAcceptTypes : UnicodeString;
1016 const aFlags : DWORD
1017 );
1018var handle : HINTERNET;
1019 accept : array[0..1] of PWideChar;
1020begin
1021 FConnection := aConnection;
1022
1023 accept[0] := PWideChar(aAcceptTypes);
1024 accept[1] := nil;
1025
1026 handle := WinHttpOpenRequest( FConnection.Handle,
1027 PWideChar(UpperCase(aVerb)),
1028 PWideChar(aObjName),
1029 PWideChar(aVersion),
1030 PWideChar(aReferrer),
1031 @accept,
1032 aFlags);
Jens Geyer433a6492019-06-19 23:14:08 +02001033 if handle = nil then RaiseLastWinHttpError;
Jens Geyer02230912019-04-03 01:12:51 +02001034 inherited Create( handle);
1035end;
1036
1037
1038destructor TWinHTTPRequestImpl.Destroy;
1039begin
1040 inherited Destroy;
1041 FConnection := nil;
1042end;
1043
1044
Jens Geyer83ff7532019-06-06 22:46:03 +02001045function TWinHTTPRequestImpl.Connection : IWinHTTPConnection;
1046begin
1047 result := FConnection;
1048end;
1049
1050
Jens Geyer02230912019-04-03 01:12:51 +02001051function TWinHTTPRequestImpl.SetTimeouts( const aResolveTimeout, aConnectTimeout, aSendTimeout, aReceiveTimeout : Int32) : Boolean;
1052begin
1053 result := WinHttpSetTimeouts( FHandle, aResolveTimeout, aConnectTimeout, aSendTimeout, aReceiveTimeout);
1054end;
1055
1056
1057function TWinHTTPRequestImpl.AddRequestHeader( const aHeader : string; const addflag : DWORD) : Boolean;
1058begin
1059 result := WinHttpAddRequestHeaders( FHandle, PWideChar(aHeader), DWORD(-1), addflag);
1060end;
1061
1062
Jens Geyer83ff7532019-06-06 22:46:03 +02001063procedure TWinHTTPRequestImpl.TryAutoProxy( const aUrl : string);
1064// From MSDN:
1065// AutoProxy support is not fully integrated into the HTTP stack in WinHTTP.
1066// Before sending a request, the application must call WinHttpGetProxyForUrl
1067// to obtain the name of a proxy server and then call WinHttpSetOption using
1068// WINHTTP_OPTION_PROXY to set the proxy configuration on the WinHTTP request
1069// handle created by WinHttpOpenRequest.
1070// See https://docs.microsoft.com/en-us/windows/desktop/winhttp/winhttp-autoproxy-api
1071var
1072 options : WINHTTP_AUTOPROXY_OPTIONS;
1073 proxy : WINHTTP_PROXY_INFO;
1074 ieProxy : WINHTTP_CURRENT_USER_IE_PROXY_CONFIG;
1075 dwSize : DWORD;
1076begin
1077 // try AutoProxy via PAC first
1078 proxy.Initialize;
1079 try
1080 FillChar( options, SizeOf(options), 0);
1081 options.dwFlags := WINHTTP_AUTOPROXY_AUTO_DETECT;
1082 options.dwAutoDetectFlags := WINHTTP_AUTO_DETECT_TYPE_DHCP or WINHTTP_AUTO_DETECT_TYPE_DNS_A;
1083 options.fAutoLogonIfChallenged := TRUE;
1084 if WinHttpGetProxyForUrl( FConnection.Session.Handle, PChar(aUrl), options, proxy) then begin
1085 dwSize := SizeOf(proxy);
1086 WinHttpSetOption( Handle, WINHTTP_OPTION_PROXY, @proxy, dwSize);
1087 Exit;
1088 end;
1089
1090 finally
1091 proxy.FreeAllocatedResources;
1092 end;
1093
1094 // Use IE settings as a fallback, useful in client (i.e. non-server) environments
1095 ieProxy.Initialize;
1096 try
1097 if WinHttpGetIEProxyConfigForCurrentUser( ieProxy)
1098 then begin
1099
1100 // lpszAutoConfigUrl = "Use automatic proxy configuration"
1101 if ieProxy.lpszAutoConfigUrl <> nil then begin
1102 options.lpszAutoConfigUrl := ieProxy.lpszAutoConfigUrl;
1103 options.dwFlags := options.dwFlags or WINHTTP_AUTOPROXY_CONFIG_URL;
1104
1105 proxy.Initialize;
1106 try
1107 if WinHttpGetProxyForUrl( FConnection.Session.Handle, PChar(aUrl), options, proxy) then begin
1108 dwSize := SizeOf(proxy);
1109 WinHttpSetOption( Handle, WINHTTP_OPTION_PROXY, @proxy, dwSize);
1110 Exit;
1111 end;
1112 finally
1113 proxy.FreeAllocatedResources;
1114 end;
1115 end;
1116
1117 // lpszProxy = "use a proxy server"
1118 if ieProxy.lpszProxy <> nil then begin
1119 proxy.Initialize;
1120 try
1121 proxy.dwAccessType := WINHTTP_ACCESS_TYPE_NAMED_PROXY;
1122 proxy.lpszProxy := ieProxy.lpszProxy;
1123 proxy.lpszProxyBypass := ieProxy.lpszProxyBypass;
1124 dwSize := SizeOf(proxy);
1125 WinHttpSetOption( Handle, WINHTTP_OPTION_PROXY, @proxy, dwSize);
1126 Exit;
1127 finally
1128 proxy.Initialize; // not FreeAllocatedResources, we only hold pointer copies!
1129 end;
1130 end;
1131
1132 end;
1133
1134 finally
1135 ieProxy.FreeAllocatedResources;
1136 end;
1137end;
1138
1139
Jens Geyer19505c32019-06-22 00:59:54 +02001140procedure TWinHTTPRequestImpl.EnableAutomaticContentDecompression( const aEnable : Boolean);
1141// Enable automatic gzip,deflate decompression on systems that support this option
1142// From the docs: WinHTTP will automatically set an appropriate Accept-Encoding header,
1143// overriding any value supplied by the caller -> we don't have to do this
1144// Available on Win 8.1 or higher
1145var value : DWORD;
1146begin
1147 if aEnable
1148 then value := WINHTTP_DECOMPRESSION_FLAG_ALL
1149 else value := 0;
1150
1151 // ignore returned value, the option is not supported with older WinHTTP versions
1152 WinHttpSetOption( Handle, WINHTTP_OPTION_DECOMPRESSION, @value, SizeOf(DWORD));
1153end;
Jens Geyer83ff7532019-06-06 22:46:03 +02001154
1155
Jens Geyer02230912019-04-03 01:12:51 +02001156function TWinHTTPRequestImpl.SendRequest( const pBuf : Pointer; const dwBytes, dwExtra : DWORD) : Boolean;
1157begin
1158 result := WinHttpSendRequest( FHandle,
1159 WINHTTP_NO_ADDITIONAL_HEADERS, 0,
1160 pBuf, dwBytes, // number of bytes in pBuf
1161 dwBytes + dwExtra, // becomes the Content-Length
1162 nil); // context for async operations
1163end;
1164
1165
1166function TWinHTTPRequestImpl.WriteExtraData( const pBuf : Pointer; const dwBytes : DWORD) : DWORD;
1167begin
1168 if not WinHttpWriteData( FHandle, pBuf, dwBytes, result)
1169 then result := 0;
1170end;
1171
1172
1173function TWinHTTPRequestImpl.FlushAndReceiveResponse : Boolean;
1174begin
1175 result := WinHttpReceiveResponse( FHandle, nil);
1176end;
1177
1178
1179function TWinHTTPRequestImpl.ReadData( const dwRead : DWORD) : TBytes;
1180var dwAvailable, dwReceived : DWORD;
1181begin
1182 if WinHttpQueryDataAvailable( FHandle, dwAvailable)
1183 then dwAvailable := Min( dwRead, dwAvailable)
1184 else dwAvailable := 0;
1185
1186 SetLength( result, dwAvailable);
1187 if dwAvailable = 0 then Exit;
1188
1189 if WinHttpReadData( FHandle, @result[0], Length(result), dwReceived)
1190 then SetLength( result, dwReceived)
1191 else SetLength( result, 0);
1192end;
1193
1194
1195function TWinHTTPRequestImpl.ReadData( const pBuf : Pointer; const dwRead : DWORD) : DWORD;
1196var dwAvailable : DWORD;
1197begin
1198 if WinHttpQueryDataAvailable( FHandle, dwAvailable)
1199 then dwAvailable := Min( dwRead, dwAvailable)
1200 else dwAvailable := 0;
1201
1202 if (dwAvailable = 0)
1203 or not WinHttpReadData( FHandle, pBuf, dwAvailable, result)
1204 then result := 0;
1205end;
1206
1207
Jens Geyer41f47af2019-11-09 23:24:52 +01001208function TWinHTTPRequestImpl.QueryDataAvailable : DWORD;
1209begin
1210 if not WinHttpQueryDataAvailable( FHandle, result)
1211 then result := 0;
1212end;
1213
1214
Jens Geyerb0123182020-02-12 12:16:19 +01001215function TWinHTTPRequestImpl.QueryTotalResponseSize( out dwSize : DWORD) : Boolean;
Jens Geyer528a0f02019-11-18 20:17:03 +01001216var dwBytes, dwError, dwIndex : DWORD;
1217begin
1218 dwBytes := SizeOf( result);
1219 dwIndex := DWORD( WINHTTP_NO_HEADER_INDEX);
Jens Geyerb0123182020-02-12 12:16:19 +01001220 result := WinHttpQueryHeaders( FHandle,
1221 WINHTTP_QUERY_CONTENT_LENGTH or WINHTTP_QUERY_FLAG_NUMBER,
1222 WINHTTP_HEADER_NAME_BY_INDEX,
1223 @dwSize, dwBytes,
1224 dwIndex);
1225 if not result then begin
1226 dwSize := MAXINT; // we don't know, just return something useful
Jens Geyer528a0f02019-11-18 20:17:03 +01001227 dwError := GetLastError;
Jens Geyera019cda2019-11-09 23:24:52 +01001228 if dwError <> ERROR_WINHTTP_HEADER_NOT_FOUND then ASSERT(FALSE); // anything else would be an real error
Jens Geyer528a0f02019-11-18 20:17:03 +01001229 end;
1230end;
1231
1232
Jens Geyer41f47af2019-11-09 23:24:52 +01001233
Jens Geyer02230912019-04-03 01:12:51 +02001234{ TWinHTTPUrlImpl }
1235
1236constructor TWinHTTPUrlImpl.Create(const aUri: UnicodeString);
1237begin
1238 inherited Create;
1239 CrackUrl( aUri)
1240end;
1241
1242
1243destructor TWinHTTPUrlImpl.Destroy;
1244begin
1245 inherited Destroy;
1246end;
1247
1248
1249procedure TWinHTTPUrlImpl.CrackURL( const value : UnicodeString);
1250const FLAGS = 0; // no special operations, leave components as-is
1251var components : URL_COMPONENTS;
1252begin
1253 FillChar(components, SizeOf(components), 0);
1254 components.dwStructSize := SizeOf(components);
1255
1256 if value <> '' then begin
1257 { For the WinHttpCrackUrl function, [...] if the pointer member is NULL but the
1258 length member is not zero, both the pointer and length members are returned. }
1259 components.dwSchemeLength := DWORD(-1);
1260 components.dwHostNameLength := DWORD(-1);
1261 components.dwUserNameLength := DWORD(-1);
1262 components.dwPasswordLength := DWORD(-1);
1263 components.dwUrlPathLength := DWORD(-1);
1264 components.dwExtraInfoLength := DWORD(-1);
1265
1266 WinHttpCrackUrl( PWideChar(value), Length(value), FLAGS, components);
1267 end;
1268
1269 FNumScheme := components.nScheme;
1270 FPort := components.nPort;
1271 SetString( FScheme, components.lpszScheme, components.dwSchemeLength);
1272 SetString( FHostName, components.lpszHostName, components.dwHostNameLength);
1273 SetString( FUserName, components.lpszUserName, components.dwUserNameLength);
1274 SetString( FPassword, components.lpszPassword, components.dwPasswordLength);
1275 SetString( FUrlPath, components.lpszUrlPath, components.dwUrlPathLength);
1276 SetString( FExtraInfo, components.lpszExtraInfo, components.dwExtraInfoLength);
1277end;
1278
1279
1280function TWinHTTPUrlImpl.BuildUrl : UnicodeString;
1281const FLAGS = 0; // no special operations, leave components as-is
1282var components : URL_COMPONENTS;
1283 dwChars : DWORD;
1284begin
1285 FillChar(components, SizeOf(components), 0);
1286 components.dwStructSize := SizeOf(components);
1287 components.lpszScheme := PWideChar(FScheme);
1288 components.dwSchemeLength := Length(FScheme);
1289 components.lpszHostName := PWideChar(FHostName);
1290 components.dwHostNameLength := Length(FHostName);
1291 components.nPort := FPort;
1292 components.lpszUserName := PWideChar(FUserName);
1293 components.dwUserNameLength := Length(FUserName);
1294 components.lpszPassword := PWideChar(FPassword);
1295 components.dwPasswordLength := Length(FPassword);
1296 components.lpszUrlPath := PWideChar(FUrlPath);
1297 components.dwUrlPathLength := Length(FUrlPath);
1298 components.lpszExtraInfo := PWideChar(FExtraInfo);
1299 components.dwExtraInfoLength := Length(FExtraInfo);
1300
1301 WinHttpCreateUrl( components, FLAGS, nil, dwChars);
1302 if dwChars = 0
1303 then result := ''
1304 else begin
1305 SetLength( result, dwChars + 1);
1306 WinHttpCreateUrl( components, FLAGS, @result[1], dwChars);
1307 SetLength( result, dwChars); // cut off terminating #0
1308 end;
1309end;
1310
1311
1312function TWinHTTPUrlImpl.GetExtraInfo: UnicodeString;
1313begin
1314 result := FExtraInfo;
1315end;
1316
1317function TWinHTTPUrlImpl.GetHostName: UnicodeString;
1318begin
1319 result := FHostName;
1320end;
1321
1322function TWinHTTPUrlImpl.GetNumScheme: INTERNET_SCHEME;
1323begin
1324 result := FNumScheme;
1325end;
1326
1327function TWinHTTPUrlImpl.GetPassword: UnicodeString;
1328begin
1329 result := FPassword;
1330end;
1331
1332function TWinHTTPUrlImpl.GetPort: INTERNET_PORT;
1333begin
1334 result := FPort;
1335end;
1336
1337function TWinHTTPUrlImpl.GetScheme: UnicodeString;
1338begin
1339 result := FScheme;
1340end;
1341
1342function TWinHTTPUrlImpl.GetUrlPath: UnicodeString;
1343begin
1344 result := FUrlPath;
1345end;
1346
1347function TWinHTTPUrlImpl.GetUserName: UnicodeString;
1348begin
1349 result := FUserName;
1350end;
1351
1352procedure TWinHTTPUrlImpl.SetExtraInfo(const value: UnicodeString);
1353begin
1354 FExtraInfo := value;
1355end;
1356
1357procedure TWinHTTPUrlImpl.SetHostName(const value: UnicodeString);
1358begin
1359 FHostName := value;
1360end;
1361
1362procedure TWinHTTPUrlImpl.SetPassword(const value: UnicodeString);
1363begin
1364 FPassword := value;
1365end;
1366
1367procedure TWinHTTPUrlImpl.SetPort(const value: INTERNET_PORT);
1368begin
1369 FPort := value;
1370end;
1371
1372procedure TWinHTTPUrlImpl.SetScheme(const value: UnicodeString);
1373begin
1374 FScheme := value;
1375end;
1376
1377procedure TWinHTTPUrlImpl.SetUrlPath(const value: UnicodeString);
1378begin
1379 FUrlPath := value;
1380end;
1381
1382procedure TWinHTTPUrlImpl.SetUserName(const value: UnicodeString);
1383begin
1384 FUserName := value;
1385end;
1386
1387
Jens Geyer433a6492019-06-19 23:14:08 +02001388initialization
1389 OutputDebugString( PChar( SysErrorMessage( 12002)));
1390
Jens Geyer02230912019-04-03 01:12:51 +02001391end.
1392
Jens Geyer83ff7532019-06-06 22:46:03 +02001393