-
-
Notifications
You must be signed in to change notification settings - Fork 137
/
Copy pathmormot.lib.winhttp.pas
2613 lines (2328 loc) · 90.9 KB
/
mormot.lib.winhttp.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/// Windows HTTP and WebSockets API Libraries
// - this unit is a part of the Open Source Synopse mORMot framework 2,
// licensed under a MPL/GPL/LGPL three license - see LICENSE.md
unit mormot.lib.winhttp;
{
*****************************************************************************
Windows HTTP and WebSockets API Libraries
- WinINet API Additional Wrappers
- http.sys / HTTP Server API low-level direct access
- winhttp.dll Windows API Definitions
- websocket.dll Windows API Definitions
*****************************************************************************
}
interface
{$I ..\mormot.defines.inc}
{$ifdef USEWININET}
// compile as a void unit if USEWININET is not defined
uses
sysutils,
classes,
windows,
wininet,
mormot.core.base,
mormot.core.os,
mormot.core.unicode,
mormot.core.text,
mormot.net.sock;
{ ******************** WinINet API Additional Wrappers }
/// retrieve extended error information text after a WinINet API call
function SysErrorMessageWinInet(error: integer): RawUtf8;
{ ************ http.sys / HTTP Server API low-level direct access }
{$MINENUMSIZE 4}
{$A+}
{$ifdef FPC}
{$packrecords C}
{$endif FPC}
type
{$ifndef UNICODE} // circumvent oldest Delphi limitation
ULONGLONG = Int64;
{$else}
ULONGLONG = Windows.ULONGLONG;
{$endif UNICODE}
TOverlapped = Windows.TOverlapped;
ULARGE_INTEGER = Windows.ULARGE_INTEGER;
HTTP_OPAQUE_ID = ULONGLONG;
HTTP_REQUEST_ID = HTTP_OPAQUE_ID;
HTTP_URL_GROUP_ID = HTTP_OPAQUE_ID;
HTTP_SERVER_SESSION_ID = HTTP_OPAQUE_ID;
/// http.sys API 2.0 logging file supported layouts
// - match low-level HTTP_LOGGING_TYPE as defined in HTTP 2.0 API
THttpApiLoggingType = (
hltW3C,
hltIIS,
hltNCSA,
hltRaw);
/// http.sys API 2.0 logging file rollover types
// - match low-level HTTP_LOGGING_ROLLOVER_TYPE as defined in HTTP 2.0 API
THttpApiLoggingRollOver = (
hlrSize,
hlrDaily,
hlrWeekly,
hlrMonthly,
hlrHourly);
/// http.sys API 2.0 logging option flags
// - used to alter the default logging behavior
// - hlfLocalTimeRollover would force the log file rollovers by local time,
// instead of the default GMT time
// - hlfUseUtf8Conversion will use UTF-8 instead of default local code page
// - only one of hlfLogErrorsOnly and hlfLogSuccessOnly flag could be set
// at a time: if neither of them are present, both errors and success will
// be logged, otherwise mutually exclusive flags could be set to force only
// errors or success logging
// - match low-level HTTP_LOGGING_FLAG_* constants as defined in HTTP 2.0 API
THttpApiLoggingFlags = set of (
hlfLocalTimeRollover,
hlfUseUtf8Conversion,
hlfLogErrorsOnly,
hlfLogSuccessOnly);
/// http.sys API 2.0 fields used for W3C logging
// - match low-level HTTP_LOG_FIELD_* constants as defined in HTTP 2.0 API
THttpApiLogFields = set of (
hlfDate,
hlfTime,
hlfClientIP,
hlfUserName,
hlfSiteName,
hlfComputerName,
hlfServerIP,
hlfMethod,
hlfUriStem,
hlfUriQuery,
hlfStatus,
hlfWIN32Status,
hlfBytesSent,
hlfBytesRecv,
hlfTimeTaken,
hlfServerPort,
hlfUserAgent,
hlfCookie,
hlfReferer,
hlfVersion,
hlfHost,
hlfSubStatus);
/// http.sys API 2.0 fields used for server-side authentication
// - as used by THttpApiServer.SetAuthenticationSchemes/AuthenticationSchemes
// - match low-level HTTP_AUTH_ENABLE_* constants as defined in HTTP 2.0 API
THttpApiRequestAuthentications = set of (
haBasic,
haDigest,
haNtlm,
haNegotiate,
haKerberos);
type
// HTTP version used
HTTP_VERSION = packed record
MajorVersion: word;
MinorVersion: word;
end;
// the req* values identify Request Headers, and resp* Response Headers
THttpHeader = (
reqCacheControl,
reqConnection,
reqDate,
reqKeepAlive,
reqPragma,
reqTrailer,
reqTransferEncoding,
reqUpgrade,
reqVia,
reqWarning,
reqAllow,
reqContentLength,
reqContentType,
reqContentEncoding,
reqContentLanguage,
reqContentLocation,
reqContentMd5,
reqContentRange,
reqExpires,
reqLastModified,
reqAccept,
reqAcceptCharset,
reqAcceptEncoding,
reqAcceptLanguage,
reqAuthorization,
reqCookie,
reqExpect,
reqFrom,
reqHost,
reqIfMatch,
reqIfModifiedSince,
reqIfNoneMatch,
reqIfRange,
reqIfUnmodifiedSince,
reqMaxForwards,
reqProxyAuthorization,
reqReferrer,
reqRange,
reqTe,
reqTranslate,
reqUserAgent,
respAcceptRanges = 20{%H-},
respAge,
respEtag,
respLocation,
respProxyAuthenticate,
respRetryAfter,
respServer,
respSetCookie,
respVary,
respWwwAuthenticate);
THttpVerb = (
hvUnparsed,
hvUnknown,
hvInvalid,
hvOPTIONS,
hvGET,
hvHEAD,
hvPOST,
hvPUT,
hvDELETE,
hvTRACE,
hvCONNECT,
hvTRACK, // used by Microsoft Cluster Server for a non-logged trace
hvMOVE,
hvCOPY,
hvPROPFIND,
hvPROPPATCH,
hvMKCOL,
hvLOCK,
hvUNLOCK,
hvSEARCH,
hvMaximum);
THttpChunkType = (
hctFromMemory,
hctFromFileHandle,
hctFromFragmentCache);
THttpServiceConfigID = (
hscIPListenList,
hscSSLCertInfo,
hscUrlAclInfo,
hscMax);
THttpServiceConfigQueryType = (
hscQueryExact,
hscQueryNext,
hscQueryMax);
HTTP_URL_CONTEXT = HTTP_OPAQUE_ID;
HTTP_CONNECTION_ID = HTTP_OPAQUE_ID;
HTTP_RAW_CONNECTION_ID = HTTP_OPAQUE_ID;
// Pointers overlap and point into pFullUrl. nil if not present.
HTTP_COOKED_URL = record
FullUrlLength: word; // in bytes not including the #0
HostLength: word; // in bytes not including the #0
AbsPathLength: word; // in bytes not including the #0
QueryStringLength: word; // in bytes not including the #0
pFullUrl: PWideChar; // points to "http://hostname:port/abs/.../path?query"
pHost: PWideChar; // points to the first char in the hostname
pAbsPath: PWideChar; // Points to the 3rd '/' char
pQueryString: PWideChar; // Points to the 1st '?' char or #0
end;
HTTP_TRANSPORT_ADDRESS = record
pRemoteAddress: PNetAddr;
pLocalAddress: PNetAddr;
end;
HTTP_UNKNOWN_HEADER = record
NameLength: word; // in bytes not including the #0
RawValueLength: word; // in bytes not including the n#0
pName: PUtf8Char; // The header name (minus the ':' character)
pRawValue: PUtf8Char; // The header value
end;
PHTTP_UNKNOWN_HEADER = ^HTTP_UNKNOWN_HEADER;
HTTP_UNKNOWN_HEADERS = array of HTTP_UNKNOWN_HEADER;
HTTP_KNOWN_HEADER = record
// warning: don't assume pRawValue is #0 terminated - use RawValueLength
RawValueLength: word;
pRawValue: PAnsiChar;
end;
PHTTP_KNOWN_HEADER = ^HTTP_KNOWN_HEADER;
HTTP_RESPONSE_HEADERS = record
// number of entries in the unknown HTTP headers array
UnknownHeaderCount: word;
// array of unknown HTTP headers
pUnknownHeaders: pointer;
// Reserved, must be 0
TrailerCount: word;
// Reserved, must be nil
pTrailers: pointer;
// Known headers
KnownHeaders: array[low(THttpHeader)..respWwwAuthenticate] of HTTP_KNOWN_HEADER;
end;
HTTP_REQUEST_HEADERS = record
// number of entries in the unknown HTTP headers array
UnknownHeaderCount: word;
// array of unknown HTTP headers
pUnknownHeaders: PHTTP_UNKNOWN_HEADER;
// Reserved, must be 0
TrailerCount: word;
// Reserved, must be nil
pTrailers: pointer;
// Known headers
// - warning: don't assume pRawValue is #0 terminated - use RawValueLength
KnownHeaders: array[low(THttpHeader)..reqUserAgent] of HTTP_KNOWN_HEADER;
end;
HTTP_BYTE_RANGE = record
StartingOffset: ULARGE_INTEGER;
Length: ULARGE_INTEGER;
end;
// we use 3 distinct HTTP_DATA_CHUNK_* records since variable records
// alignment is buggy/non compatible under Delphi XE3
HTTP_DATA_CHUNK_INMEMORY = record
DataChunkType: THttpChunkType; // always hctFromMemory
Reserved1: ULONG;
pBuffer: pointer;
BufferLength: ULONG;
Reserved2: ULONG;
Reserved3: ULONG;
end;
PHTTP_DATA_CHUNK_INMEMORY = ^HTTP_DATA_CHUNK_INMEMORY;
HTTP_DATA_CHUNK_FILEHANDLE = record
DataChunkType: THttpChunkType; // always hctFromFileHandle
ByteRange: HTTP_BYTE_RANGE;
FileHandle: THandle;
end;
HTTP_DATA_CHUNK_FRAGMENTCACHE = record
DataChunkType: THttpChunkType; // always hctFromFragmentCache
FragmentNameLength: word; // in bytes not including the #0
pFragmentName: PWideChar;
end;
HTTP_SSL_CLIENT_CERT_INFO = record
CertFlags: ULONG;
CertEncodedSize: ULONG;
pCertEncoded: PUCHAR;
Token: THandle;
CertDeniedByMapper: boolean;
end;
PHTTP_SSL_CLIENT_CERT_INFO = ^HTTP_SSL_CLIENT_CERT_INFO;
HTTP_SSL_INFO = record
ServerCertKeySize: word;
ConnectionKeySize: word;
ServerCertIssuerSize: ULONG;
ServerCertSubjectSize: ULONG;
pServerCertIssuer: PAnsiChar;
pServerCertSubject: PAnsiChar;
pClientCertInfo: PHTTP_SSL_CLIENT_CERT_INFO;
SslClientCertNegotiated: ULONG;
end;
PHTTP_SSL_INFO = ^HTTP_SSL_INFO;
HTTP_SERVICE_CONFIG_URLACL_KEY = record
pUrlPrefix: PWideChar;
end;
HTTP_SERVICE_CONFIG_URLACL_PARAM = record
pStringSecurityDescriptor: PWideChar;
end;
HTTP_SERVICE_CONFIG_URLACL_SET = record
KeyDesc: HTTP_SERVICE_CONFIG_URLACL_KEY;
ParamDesc: HTTP_SERVICE_CONFIG_URLACL_PARAM;
end;
HTTP_SERVICE_CONFIG_URLACL_QUERY = record
QueryDesc: THttpServiceConfigQueryType;
KeyDesc: HTTP_SERVICE_CONFIG_URLACL_KEY;
dwToken: DWORD;
end;
HTTP_REQUEST_INFO_TYPE = (
HttpRequestInfoTypeAuth,
HttpRequestInfoTypeChannelBind,
HttpRequestInfoTypeSslProtocol,
HttpRequestInfoTypeSslTokenBindingDraft,
HttpRequestInfoTypeSslTokenBinding,
HttpRequestInfoTypeRequestTiming,
HttpRequestInfoTypeTcpInfoV0,
HttpRequestInfoTypeRequestSizing,
HttpRequestInfoTypeQuicStats,
HttpRequestInfoTypeTcpInfoV1);
// about Authentication in HTTP Version 2.0
// see https://msdn.microsoft.com/en-us/library/windows/desktop/aa364452
HTTP_AUTH_STATUS = (
HttpAuthStatusSuccess,
HttpAuthStatusNotAuthenticated,
HttpAuthStatusFailure);
HTTP_REQUEST_AUTH_TYPE = (
HttpRequestAuthTypeNone,
HttpRequestAuthTypeBasic,
HttpRequestAuthTypeDigest,
HttpRequestAuthTypeNTLM,
HttpRequestAuthTypeNegotiate,
HttpRequestAuthTypeKerberos);
SECURITY_STATUS = ULONG;
HTTP_REQUEST_AUTH_INFO = record
AuthStatus: HTTP_AUTH_STATUS;
SecStatus: SECURITY_STATUS;
Flags: ULONG;
AuthType: HTTP_REQUEST_AUTH_TYPE;
AccessToken: THandle;
ContextAttributes: ULONG;
PackedContextLength: ULONG;
PackedContextType: ULONG;
PackedContext: pointer;
MutualAuthDataLength: ULONG;
pMutualAuthData: PAnsiChar;
PackageNameLength: word;
pPackageName: LPWSTR;
end;
PHTTP_REQUEST_AUTH_INFO = ^HTTP_REQUEST_AUTH_INFO;
HTTP_REQUEST_INFO = record
InfoType: HTTP_REQUEST_INFO_TYPE;
InfoLength: ULONG;
pInfo: pointer;
end;
HTTP_REQUEST_INFOS = array[0..1000] of HTTP_REQUEST_INFO;
PHTTP_REQUEST_INFOS = ^HTTP_REQUEST_INFOS;
/// structure used to handle data associated with a specific request
HTTP_REQUEST = record
// either 0 (Only Header), either HTTP_RECEIVE_REQUEST_FLAG_COPY_BODY
Flags: cardinal;
// An identifier for the connection on which the request was received
ConnectionId: HTTP_CONNECTION_ID;
// A value used to identify the request when calling
// HttpReceiveRequestEntityBody, HttpSendHttpResponse, and/or
// HttpSendResponseEntityBody
RequestId: HTTP_REQUEST_ID;
// The context associated with the URL prefix
UrlContext: HTTP_URL_CONTEXT;
// The HTTP version number
Version: HTTP_VERSION;
// An HTTP verb associated with this request
Verb: THttpVerb;
// The length of the verb string if the Verb field is hvUnknown
// (in bytes not including the last #0)
UnknownVerbLength: word;
// The length of the raw (uncooked) URL (in bytes not including the last #0)
RawUrlLength: word;
// Pointer to the verb string if the Verb field is hvUnknown
pUnknownVerb: PAnsiChar;
// Pointer to the raw (uncooked) URL
pRawUrl: PAnsiChar;
// The canonicalized Unicode URL
CookedUrl: HTTP_COOKED_URL;
// Local and remote transport addresses for the connection
Address: HTTP_TRANSPORT_ADDRESS;
// The request headers.
Headers: HTTP_REQUEST_HEADERS;
// The total number of bytes received from network for this request
BytesReceived: ULONGLONG;
EntityChunkCount: word;
pEntityChunks: pointer;
RawConnectionId: HTTP_RAW_CONNECTION_ID;
// TLS connection information
pSslInfo: PHTTP_SSL_INFO;
{ beginning of HTTP_REQUEST_V2 structure - manual padding is needed :( }
{$ifdef CPU32}
padding: dword;
{$endif CPU32}
/// how many extended info about a specific request is available in v2
RequestInfoCount: word;
/// v2 trailing structure used to handle extended info about a specific request
pRequestInfo: PHTTP_REQUEST_INFOS;
end;
PHTTP_REQUEST = ^HTTP_REQUEST;
HTTP_RESPONSE_INFO_TYPE = (
HttpResponseInfoTypeMultipleKnownHeaders,
HttpResponseInfoTypeAuthenticationProperty,
HttpResponseInfoTypeQosProperty,
HttpResponseInfoTypeChannelBind);
HTTP_RESPONSE_INFO = record
Typ: HTTP_RESPONSE_INFO_TYPE;
Length: ULONG;
pInfo: pointer;
end;
PHTTP_RESPONSE_INFO = ^HTTP_RESPONSE_INFO;
/// structure as expected by HttpSendHttpResponse() API
{$ifdef USERECORDWITHMETHODS}
HTTP_RESPONSE = record
{$else}
HTTP_RESPONSE = object
{$endif USERECORDWITHMETHODS}
public
Flags: cardinal;
// The raw HTTP protocol version number
Version: HTTP_VERSION;
// The HTTP status code (e.g., 200)
StatusCode: word;
// in bytes not including the '\0'
ReasonLength: word;
// The HTTP reason (e.g., "OK"). This MUST not contain non-ASCII characters
// (i.e., all chars must be in range 0x20-0x7E).
pReason: PUtf8Char;
// The response headers
Headers: HTTP_RESPONSE_HEADERS;
// number of elements in pEntityChunks[] array
EntityChunkCount: word;
// pEntityChunks points to an array of EntityChunkCount HTTP_DATA_CHUNK_*
pEntityChunks: pointer;
// contains the number of HTTP API 2.0 extended information
ResponseInfoCount: word;
// map the HTTP API 2.0 extended information
pResponseInfo: PHTTP_RESPONSE_INFO;
// will set both StatusCode and Reason
// - OutStatus is a temporary variable which will be field with the
// corresponding text
procedure SetStatus(code: integer; var OutStatus: RawUtf8);
// will set the content of the reponse, and ContentType header
procedure SetContent(var DataChunk: HTTP_DATA_CHUNK_INMEMORY; const Content:
RawByteString; const ContentType: RawUtf8 = 'text/html');
/// will set all header values from lines
// - Content-Type/Content-Encoding/Location will be set in KnownHeaders[]
// - all other headers will be set in temp UnknownHeaders[]
procedure SetHeaders(P: PUtf8Char; var UnknownHeaders: HTTP_UNKNOWN_HEADERS;
NoXPoweredHeader: boolean);
/// add one header value to the internal headers
// - SetHeaders() method should have been called before to initialize the
// internal UnknownHeaders[] array
function AddCustomHeader(P: PUtf8Char; var UnknownHeaders:
HTTP_UNKNOWN_HEADERS; ForceCustomHeader: boolean): PUtf8Char;
end;
PHTTP_RESPONSE = ^HTTP_RESPONSE;
HTTP_PROPERTY_FLAGS = ULONG;
HTTP_ENABLED_STATE = (
HttpEnabledStateActive,
HttpEnabledStateInactive);
PHTTP_ENABLED_STATE = ^HTTP_ENABLED_STATE;
HTTP_STATE_INFO = record
Flags: HTTP_PROPERTY_FLAGS;
State: HTTP_ENABLED_STATE;
end;
PHTTP_STATE_INFO = ^HTTP_STATE_INFO;
THTTP_503_RESPONSE_VERBOSITY = (
Http503ResponseVerbosityBasic,
Http503ResponseVerbosityLimited,
Http503ResponseVerbosityFull);
PHTTP_503_RESPONSE_VERBOSITY = ^THTTP_503_RESPONSE_VERBOSITY;
HTTP_QOS_SETTING_TYPE = (
HttpQosSettingTypeBandwidth,
HttpQosSettingTypeConnectionLimit,
HttpQosSettingTypeFlowRate // Windows Server 2008 R2 and Windows 7 only
);
PHTTP_QOS_SETTING_TYPE = ^HTTP_QOS_SETTING_TYPE;
HTTP_QOS_SETTING_INFO = record
QosType: HTTP_QOS_SETTING_TYPE;
QosSetting: pointer;
end;
PHTTP_QOS_SETTING_INFO = ^HTTP_QOS_SETTING_INFO;
HTTP_CONNECTION_LIMIT_INFO = record
Flags: HTTP_PROPERTY_FLAGS;
MaxConnections: ULONG;
end;
PHTTP_CONNECTION_LIMIT_INFO = ^HTTP_CONNECTION_LIMIT_INFO;
HTTP_BANDWIDTH_LIMIT_INFO = record
Flags: HTTP_PROPERTY_FLAGS;
MaxBandwidth: ULONG;
end;
PHTTP_BANDWIDTH_LIMIT_INFO = ^HTTP_BANDWIDTH_LIMIT_INFO;
HTTP_FLOWRATE_INFO = record
Flags: HTTP_PROPERTY_FLAGS;
MaxBandwidth: ULONG;
MaxPeakBandwidth: ULONG;
BurstSize: ULONG;
end;
PHTTP_FLOWRATE_INFO = ^HTTP_FLOWRATE_INFO;
const
HTTP_MIN_ALLOWED_BANDWIDTH_THROTTLING_RATE {:ULONG} = 1024;
HTTP_LIMIT_INFINITE {:ULONG} = ULONG(-1);
type
HTTP_SERVICE_CONFIG_TIMEOUT_KEY = (
IdleConnectionTimeout,
HeaderWaitTimeout);
PHTTP_SERVICE_CONFIG_TIMEOUT_KEY = ^HTTP_SERVICE_CONFIG_TIMEOUT_KEY;
HTTP_SERVICE_CONFIG_TIMEOUT_PARAM = word;
PHTTP_SERVICE_CONFIG_TIMEOUT_PARAM = ^HTTP_SERVICE_CONFIG_TIMEOUT_PARAM;
HTTP_SERVICE_CONFIG_TIMEOUT_SET = record
KeyDesc: HTTP_SERVICE_CONFIG_TIMEOUT_KEY;
ParamDesc: HTTP_SERVICE_CONFIG_TIMEOUT_PARAM;
end;
PHTTP_SERVICE_CONFIG_TIMEOUT_SET = ^HTTP_SERVICE_CONFIG_TIMEOUT_SET;
HTTP_TIMEOUT_LIMIT_INFO = record
Flags: HTTP_PROPERTY_FLAGS;
EntityBody: word;
DrainEntityBody: word;
RequestQueue: word;
IdleConnection: word;
HeaderWait: word;
MinSendRate: cardinal;
end;
PHTTP_TIMEOUT_LIMIT_INFO = ^HTTP_TIMEOUT_LIMIT_INFO;
HTTP_LISTEN_ENDPOINT_INFO = record
Flags: HTTP_PROPERTY_FLAGS;
EnableSharing: boolean;
end;
PHTTP_LISTEN_ENDPOINT_INFO = ^HTTP_LISTEN_ENDPOINT_INFO;
HTTP_SERVER_AUTHENTICATION_DIGEST_PARAMS = record
DomainNameLength: word;
DomainName: PWideChar;
RealmLength: word;
Realm: PWideChar;
end;
PHTTP_SERVER_AUTHENTICATION_DIGEST_PARAMS = ^HTTP_SERVER_AUTHENTICATION_DIGEST_PARAMS;
HTTP_SERVER_AUTHENTICATION_BASIC_PARAMS = record
RealmLength: word;
Realm: PWideChar;
end;
PHTTP_SERVER_AUTHENTICATION_BASIC_PARAMS = ^HTTP_SERVER_AUTHENTICATION_BASIC_PARAMS;
const
HTTP_AUTH_ENABLE_BASIC = $00000001;
HTTP_AUTH_ENABLE_DIGEST = $00000002;
HTTP_AUTH_ENABLE_NTLM = $00000004;
HTTP_AUTH_ENABLE_NEGOTIATE = $00000008;
HTTP_AUTH_ENABLE_KERBEROS = $00000010;
HTTP_AUTH_ENABLE_ALL = $0000001F;
HTTP_AUTH_EX_FLAG_ENABLE_KERBEROS_CREDENTIAL_CACHING = $01;
HTTP_AUTH_EX_FLAG_CAPTURE_CREDENTIAL = $02;
type
HTTP_SERVER_AUTHENTICATION_INFO = record
Flags: HTTP_PROPERTY_FLAGS;
AuthSchemes: ULONG;
ReceiveMutualAuth: BYTEBOOL;
ReceiveContextHandle: BYTEBOOL;
DisableNTLMCredentialCaching: BYTEBOOL;
ExFlags: BYTE;
DigestParams: HTTP_SERVER_AUTHENTICATION_DIGEST_PARAMS;
BasicParams: HTTP_SERVER_AUTHENTICATION_BASIC_PARAMS;
end;
PHTTP_SERVER_AUTHENTICATION_INFO = ^HTTP_SERVER_AUTHENTICATION_INFO;
HTTP_SERVICE_BINDING_TYPE = (
HttpServiceBindingTypeNone,
HttpServiceBindingTypeW,
HttpServiceBindingTypeA);
HTTP_SERVICE_BINDING_BASE = record
BindingType: HTTP_SERVICE_BINDING_TYPE;
end;
PHTTP_SERVICE_BINDING_BASE = ^HTTP_SERVICE_BINDING_BASE;
HTTP_SERVICE_BINDING_A = record
Base: HTTP_SERVICE_BINDING_BASE;
Buffer: PAnsiChar;
BufferSize: ULONG;
end;
PHTTP_SERVICE_BINDING_A = HTTP_SERVICE_BINDING_A;
HTTP_SERVICE_BINDING_W = record
Base: HTTP_SERVICE_BINDING_BASE;
Buffer: PWCHAR;
BufferSize: ULONG;
end;
PHTTP_SERVICE_BINDING_W = ^HTTP_SERVICE_BINDING_W;
HTTP_AUTHENTICATION_HARDENING_LEVELS = (
HttpAuthenticationHardeningLegacy,
HttpAuthenticationHardeningMedium,
HttpAuthenticationHardeningStrict);
const
HTTP_CHANNEL_BIND_PROXY = $1;
HTTP_CHANNEL_BIND_PROXY_COHOSTING = $20;
HTTP_CHANNEL_BIND_NO_SERVICE_NAME_CHECK = $2;
HTTP_CHANNEL_BIND_DOTLESS_SERVICE = $4;
HTTP_CHANNEL_BIND_SECURE_CHANNEL_TOKEN = $8;
HTTP_CHANNEL_BIND_CLIENT_SERVICE = $10;
type
HTTP_CHANNEL_BIND_INFO = record
Hardening: HTTP_AUTHENTICATION_HARDENING_LEVELS;
Flags: ULONG;
ServiceNames: PHTTP_SERVICE_BINDING_BASE;
NumberOfServiceNames: ULONG;
end;
PHTTP_CHANNEL_BIND_INFO = ^HTTP_CHANNEL_BIND_INFO;
HTTP_REQUEST_CHANNEL_BIND_STATUS = record
ServiceName: PHTTP_SERVICE_BINDING_BASE;
ChannelToken: PUCHAR;
ChannelTokenSize: ULONG;
Flags: ULONG;
end;
PHTTP_REQUEST_CHANNEL_BIND_STATUS = ^HTTP_REQUEST_CHANNEL_BIND_STATUS;
const
// Logging option flags. When used in the logging configuration alters
// some default logging behaviour.
// HTTP_LOGGING_FLAG_LOCAL_TIME_ROLLOVER - This flag is used to change
// the log file rollover to happen by local time based. By default
// log file rollovers happen by GMT time.
HTTP_LOGGING_FLAG_LOCAL_TIME_ROLLOVER = 1;
// HTTP_LOGGING_FLAG_USE_UTF8_CONVERSION - When set the unicode fields
// will be converted to UTF-8 multibytes when writing to the log
// files. When this flag is not present, the local code page
// conversion happens.
HTTP_LOGGING_FLAG_USE_UTF8_CONVERSION = 2;
// HTTP_LOGGING_FLAG_LOG_ERRORS_ONLY -
// HTTP_LOGGING_FLAG_LOG_SUCCESS_ONLY - These two flags are used to
// to do selective logging. If neither of them are present both
// types of requests will be logged. Only one these flags can be
// set at a time. They are mutually exclusive.
HTTP_LOGGING_FLAG_LOG_ERRORS_ONLY = 4;
HTTP_LOGGING_FLAG_LOG_SUCCESS_ONLY = 8;
// The known log fields recognized/supported by HTTPAPI. Following fields
// are used for W3C logging. Subset of them are also used for error logging
HTTP_LOG_FIELD_DATE = $00000001;
HTTP_LOG_FIELD_TIME = $00000002;
HTTP_LOG_FIELD_CLIENT_IP = $00000004;
HTTP_LOG_FIELD_USER_NAME = $00000008;
HTTP_LOG_FIELD_SITE_NAME = $00000010;
HTTP_LOG_FIELD_COMPUTER_NAME = $00000020;
HTTP_LOG_FIELD_SERVER_IP = $00000040;
HTTP_LOG_FIELD_METHOD = $00000080;
HTTP_LOG_FIELD_URI_STEM = $00000100;
HTTP_LOG_FIELD_URI_QUERY = $00000200;
HTTP_LOG_FIELD_STATUS = $00000400;
HTTP_LOG_FIELD_WIN32_STATUS = $00000800;
HTTP_LOG_FIELD_BYTES_SENT = $00001000;
HTTP_LOG_FIELD_BYTES_RECV = $00002000;
HTTP_LOG_FIELD_TIME_TAKEN = $00004000;
HTTP_LOG_FIELD_SERVER_PORT = $00008000;
HTTP_LOG_FIELD_USER_AGENT = $00010000;
HTTP_LOG_FIELD_COOKIE = $00020000;
HTTP_LOG_FIELD_REFERER = $00040000;
HTTP_LOG_FIELD_VERSION = $00080000;
HTTP_LOG_FIELD_HOST = $00100000;
HTTP_LOG_FIELD_SUB_STATUS = $00200000;
HTTP_ALL_NON_ERROR_LOG_FIELDS = HTTP_LOG_FIELD_SUB_STATUS * 2 - 1;
// Fields that are used only for error logging
HTTP_LOG_FIELD_CLIENT_PORT = $00400000;
HTTP_LOG_FIELD_URI = $00800000;
HTTP_LOG_FIELD_SITE_ID = $01000000;
HTTP_LOG_FIELD_REASON = $02000000;
HTTP_LOG_FIELD_QUEUE_NAME = $04000000;
type
HTTP_LOGGING_TYPE = (
HttpLoggingTypeW3C,
HttpLoggingTypeIIS,
HttpLoggingTypeNCSA,
HttpLoggingTypeRaw);
HTTP_LOGGING_ROLLOVER_TYPE = (
HttpLoggingRolloverSize,
HttpLoggingRolloverDaily,
HttpLoggingRolloverWeekly,
HttpLoggingRolloverMonthly,
HttpLoggingRolloverHourly);
HTTP_LOGGING_INFO = record
Flags: HTTP_PROPERTY_FLAGS;
LoggingFlags: ULONG;
SoftwareName: PWideChar;
SoftwareNameLength: word;
DirectoryNameLength: word;
DirectoryName: PWideChar;
Format: HTTP_LOGGING_TYPE;
Fields: ULONG;
pExtFields: pointer;
NumOfExtFields: word;
MaxRecordSize: word;
RolloverType: HTTP_LOGGING_ROLLOVER_TYPE;
RolloverSize: ULONG;
pSecurityDescriptor: PSECURITY_DESCRIPTOR;
end;
PHTTP_LOGGING_INFO = ^HTTP_LOGGING_INFO;
HTTP_LOG_DATA_TYPE = (
HttpLogDataTypeFields);
HTTP_LOG_DATA = record
Typ: HTTP_LOG_DATA_TYPE
end;
PHTTP_LOG_DATA = ^HTTP_LOG_DATA;
HTTP_LOG_FIELDS_DATA = record
Base: HTTP_LOG_DATA;
UserNameLength: word;
UriStemLength: word;
ClientIpLength: word;
ServerNameLength: word;
ServiceNameLength: word;
ServerIpLength: word;
MethodLength: word;
UriQueryLength: word;
HostLength: word;
UserAgentLength: word;
CookieLength: word;
ReferrerLength: word;
UserName: PWideChar;
UriStem: PWideChar;
ClientIp: PAnsiChar;
ServerName: PAnsiChar;
ServiceName: PAnsiChar;
ServerIp: PAnsiChar;
Method: PAnsiChar;
UriQuery: PAnsiChar;
Host: PAnsiChar;
UserAgent: PAnsiChar;
Cookie: PAnsiChar;
Referrer: PAnsiChar;
ServerPort: word;
ProtocolStatus: word;
Win32Status: ULONG;
MethodNum: THttpVerb;
SubStatus: word;
end;
PHTTP_LOG_FIELDS_DATA = ^HTTP_LOG_FIELDS_DATA;
HTTP_BINDING_INFO = record
Flags: HTTP_PROPERTY_FLAGS;
RequestQueueHandle: THandle;
end;
HTTP_PROTECTION_LEVEL_TYPE = (
HttpProtectionLevelUnrestricted,
HttpProtectionLevelEdgeRestricted,
HttpProtectionLevelRestricted);
HTTP_PROTECTION_LEVEL_INFO = record
Flags: HTTP_PROPERTY_FLAGS;
Level: HTTP_PROTECTION_LEVEL_TYPE;
end;
PHTTP_PROTECTION_LEVEL_INFO = ^HTTP_PROTECTION_LEVEL_INFO;
const
HTTP_VERSION_UNKNOWN: HTTP_VERSION = (
MajorVersion: 0;
MinorVersion: 0
);
HTTP_VERSION_0_9: HTTP_VERSION = (
MajorVersion: 0;
MinorVersion: 9
);
HTTP_VERSION_1_0: HTTP_VERSION = (
MajorVersion: 1;
MinorVersion: 0
);
HTTP_VERSION_1_1: HTTP_VERSION = (
MajorVersion: 1;
MinorVersion: 1
);
HTTP_VERSION_1_2: HTTP_VERSION = (
MajorVersion: 1;
MinorVersion: 2
);
/// error raised by HTTP API when the client disconnected (e.g. after timeout)
HTTPAPI_ERROR_NONEXISTENTCONNECTION = 1229;
// if set, available entity body is copied along with the request headers
// into pEntityChunks
HTTP_RECEIVE_REQUEST_FLAG_COPY_BODY = 1;
// there is more entity body to be read for this request
HTTP_REQUEST_FLAG_MORE_ENTITY_BODY_EXISTS = 1;
// request was routed based on host and IP binding
HTTP_REQUEST_FLAG_IP_ROUTED = 2;
// request was received over HTTP/2
HTTP_REQUEST_FLAG_HTTP2 = 4;
// initialization for applications that use the HTTP Server API
HTTP_INITIALIZE_SERVER = 1;
// initialization for applications that use the HTTP configuration functions
HTTP_INITIALIZE_CONFIG = 2;
// see http://msdn.microsoft.com/en-us/library/windows/desktop/aa364496
HTTP_RECEIVE_REQUEST_ENTITY_BODY_FLAG_FILL_BUFFER = 1;
// see http://msdn.microsoft.com/en-us/library/windows/desktop/aa364499
HTTP_SEND_RESPONSE_FLAG_DISCONNECT = $00000001;
HTTP_SEND_RESPONSE_FLAG_MORE_DATA = $00000002;
HTTP_SEND_RESPONSE_FLAG_BUFFER_DATA = $00000004;
HTTP_SEND_RESPONSE_FLAG_PROCESS_RANGES = $00000020;
HTTP_SEND_RESPONSE_FLAG_OPAQUE = $00000040;
// flag which can be used by HttpRemoveUrlFromUrlGroup()
HTTP_URL_FLAG_REMOVE_ALL = 1;
HTTP_KNOWNHEADERS: array[low(THttpHeader)..reqUserAgent] of string[19] = (
'Cache-Control',
'Connection',
'Date',
'Keep-Alive',
'Pragma',
'Trailer',
'Transfer-Encoding',
'Upgrade',
'Via',
'Warning',
'Allow',
'Content-Length',
'Content-Type',
'Content-Encoding',
'Content-Language',
'Content-Location',
'Content-MD5',
'Content-Range',
'Expires',
'Last-Modified',
'Accept',
'Accept-Charset',
'Accept-Encoding',
'Accept-Language',
'Authorization',
'Cookie',
'Expect',
'From',
'Host',
'If-Match',
'If-Modified-Since',
'If-None-Match',
'If-Range',
'If-Unmodified-Since',
'Max-Forwards',
'Proxy-Authorization',
'Referer',
'Range',
'TE',
'Translate',
'User-Agent');
type
HTTP_SERVER_PROPERTY = (
HttpServerAuthenticationProperty,
HttpServerLoggingProperty,
HttpServerQosProperty,