1 /* 2 * HTTP Server API definitions 3 * 4 * Copyright (C) 2009 Andrey Turkin 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 */ 20 21 #ifndef __WINE_HTTP_H 22 #define __WINE_HTTP_H 23 24 #include <winsock2.h> 25 #include <ws2tcpip.h> 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 typedef struct _HTTPAPI_VERSION 32 { 33 USHORT HttpApiMajorVersion; 34 USHORT HttpApiMinorVersion; 35 } HTTPAPI_VERSION, *PHTTPAPI_VERSION; 36 37 #define HTTPAPI_VERSION_1 {1,0} 38 #define HTTPAPI_VERSION_2 {2,0} 39 40 #define HTTP_CREATE_REQUEST_QUEUE_FLAG_OPEN_EXISTING 0x00000001 41 #define HTTP_CREATE_REQUEST_QUEUE_FLAG_CONTROLLER 0x00000002 42 43 #define HTTP_INITIALIZE_SERVER 0x00000001 44 #define HTTP_INITIALIZE_CONFIG 0x00000002 45 46 #define HTTP_RECEIVE_REQUEST_FLAG_COPY_BODY 0x00000001 47 #define HTTP_RECEIVE_REQUEST_FLAG_FLUSH_BODY 0x00000002 48 49 #define HTTP_REQUEST_FLAG_MORE_ENTITY_BODY_EXISTS 0x00000001 50 #define HTTP_REQUEST_FLAG_IP_ROUTED 0x00000002 51 #define HTTP_REQUEST_FLAG_HTTP2 0x00000004 52 53 #define HTTP_SEND_RESPONSE_FLAG_DISCONNECT 0x00000001 54 #define HTTP_SEND_RESPONSE_FLAG_MORE_DATA 0x00000002 55 #define HTTP_SEND_RESPONSE_FLAG_BUFFER_DATA 0x00000004 56 #define HTTP_SEND_RESPONSE_FLAG_ENABLE_NAGLING 0x00000008 57 #define HTTP_SEND_RESPONSE_FLAG_PROCESS_RANGES 0x00000020 58 #define HTTP_SEND_RESPONSE_FLAG_OPAQUE 0x00000040 59 60 #define HTTP_URL_FLAG_REMOVE_ALL 0x0000001 61 62 typedef enum _HTTP_SERVICE_CONFIG_ID 63 { 64 HttpServiceConfigIPListenList, 65 HttpServiceConfigSSLCertInfo, 66 HttpServiceConfigUrlAclInfo, 67 HttpServiceConfigTimeout, 68 HttpServiceConfigMax 69 } HTTP_SERVICE_CONFIG_ID, *PHTTP_SERVICE_CONFIG_ID; 70 71 #define HTTP_NULL_ID ((ULONGLONG)0) 72 73 typedef ULONGLONG HTTP_OPAQUE_ID, *PHTTP_OPAQUE_ID; 74 typedef HTTP_OPAQUE_ID HTTP_CONNECTION_ID, *PHTTP_CONNECTION_ID; 75 typedef HTTP_OPAQUE_ID HTTP_RAW_CONNECTION_ID, *PHTTP_RAW_CONNECTION_ID; 76 typedef HTTP_OPAQUE_ID HTTP_REQUEST_ID, *PHTTP_REQUEST_ID; 77 typedef HTTP_OPAQUE_ID HTTP_SERVER_SESSION_ID, *PHTTP_SERVER_SESSION_ID; 78 typedef HTTP_OPAQUE_ID HTTP_URL_GROUP_ID, *PHTTP_URL_GROUP_ID; 79 typedef ULONGLONG HTTP_URL_CONTEXT; 80 81 typedef struct _HTTP_VERSION 82 { 83 USHORT MajorVersion; 84 USHORT MinorVersion; 85 } HTTP_VERSION, *PHTTP_VERSION; 86 87 typedef enum _HTTP_VERB 88 { 89 HttpVerbUnparsed = 0, 90 HttpVerbUnknown, 91 HttpVerbInvalid, 92 HttpVerbOPTIONS, 93 HttpVerbGET, 94 HttpVerbHEAD, 95 HttpVerbPOST, 96 HttpVerbPUT, 97 HttpVerbDELETE, 98 HttpVerbTRACE, 99 HttpVerbCONNECT, 100 HttpVerbTRACK, 101 HttpVerbMOVE, 102 HttpVerbCOPY, 103 HttpVerbPROPFIND, 104 HttpVerbPROPPATCH, 105 HttpVerbMKCOL, 106 HttpVerbLOCK, 107 HttpVerbUNLOCK, 108 HttpVerbSEARCH, 109 HttpVerbMaximum, 110 } HTTP_VERB, *PHTTP_VERB; 111 112 typedef struct _HTTP_COOKED_URL 113 { 114 USHORT FullUrlLength; 115 USHORT HostLength; 116 USHORT AbsPathLength; 117 USHORT QueryStringLength; 118 const WCHAR *pFullUrl; 119 const WCHAR *pHost; 120 const WCHAR *pAbsPath; 121 const WCHAR *pQueryString; 122 } HTTP_COOKED_URL, *PHTTP_COOKED_URL; 123 124 typedef struct _HTTP_TRANSPORT_ADDRESS 125 { 126 SOCKADDR *pRemoteAddress; 127 SOCKADDR *pLocalAddress; 128 } HTTP_TRANSPORT_ADDRESS, *PHTTP_TRANSPORT_ADDRESS; 129 130 typedef struct _HTTP_UNKNOWN_HEADER 131 { 132 USHORT NameLength; 133 USHORT RawValueLength; 134 const char *pName; 135 const char *pRawValue; 136 } HTTP_UNKNOWN_HEADER, *PHTTP_UNKNOWN_HEADER; 137 138 typedef struct _HTTP_KNOWN_HEADER 139 { 140 USHORT RawValueLength; 141 const char *pRawValue; 142 } HTTP_KNOWN_HEADER, *PHTTP_KNOWN_HEADER; 143 144 typedef enum _HTTP_HEADER_ID 145 { 146 HttpHeaderCacheControl = 0, 147 HttpHeaderConnection = 1, 148 HttpHeaderDate = 2, 149 HttpHeaderKeepAlive = 3, 150 HttpHeaderPragma = 4, 151 HttpHeaderTrailer = 5, 152 HttpHeaderTransferEncoding = 6, 153 HttpHeaderUpgrade = 7, 154 HttpHeaderVia = 8, 155 HttpHeaderWarning = 9, 156 HttpHeaderAllow = 10, 157 HttpHeaderContentLength = 11, 158 HttpHeaderContentType = 12, 159 HttpHeaderContentEncoding = 13, 160 HttpHeaderContentLanguage = 14, 161 HttpHeaderContentLocation = 15, 162 HttpHeaderContentMd5 = 16, 163 HttpHeaderContentRange = 17, 164 HttpHeaderExpires = 18, 165 HttpHeaderLastModified = 19, 166 167 HttpHeaderAccept = 20, 168 HttpHeaderAcceptCharset = 21, 169 HttpHeaderAcceptEncoding = 22, 170 HttpHeaderAcceptLanguage = 23, 171 HttpHeaderAuthorization = 24, 172 HttpHeaderCookie = 25, 173 HttpHeaderExpect = 26, 174 HttpHeaderFrom = 27, 175 HttpHeaderHost = 28, 176 HttpHeaderIfMatch = 29, 177 HttpHeaderIfModifiedSince = 30, 178 HttpHeaderIfNoneMatch = 31, 179 HttpHeaderIfRange = 32, 180 HttpHeaderIfUnmodifiedSince = 33, 181 HttpHeaderMaxForwards = 34, 182 HttpHeaderProxyAuthorization = 35, 183 HttpHeaderReferer = 36, 184 HttpHeaderRange = 37, 185 HttpHeaderTe = 38, 186 HttpHeaderTranslate = 39, 187 HttpHeaderUserAgent = 40, 188 HttpHeaderRequestMaximum = 41, 189 190 HttpHeaderAcceptRanges = 20, 191 HttpHeaderAge = 21, 192 HttpHeaderEtag = 22, 193 HttpHeaderLocation = 23, 194 HttpHeaderProxyAuthenticate = 24, 195 HttpHeaderRetryAfter = 25, 196 HttpHeaderServer = 26, 197 HttpHeaderSetCookie = 27, 198 HttpHeaderVary = 28, 199 HttpHeaderWwwAuthenticate = 29, 200 HttpHeaderResponseMaximum = 30, 201 202 HttpHeaderMaximum = 41, 203 } HTTP_HEADER_ID, *PHTTP_HEADER_ID; 204 205 typedef struct _HTTP_REQUEST_HEADERS 206 { 207 USHORT UnknownHeaderCount; 208 HTTP_UNKNOWN_HEADER *pUnknownHeaders; 209 USHORT TrailerCount; 210 HTTP_UNKNOWN_HEADER *pTrailers; 211 HTTP_KNOWN_HEADER KnownHeaders[HttpHeaderRequestMaximum]; 212 } HTTP_REQUEST_HEADERS, *PHTTP_REQUEST_HEADERS; 213 214 typedef enum _HTTP_DATA_CHUNK_TYPE 215 { 216 HttpDataChunkFromMemory = 0, 217 HttpDataChunkFromFileHandle, 218 HttpDataChunkFromFragmentCache, 219 HttpDataChunkFromFragmentCacheEx, 220 HttpDataChunkMaximum, 221 } HTTP_DATA_CHUNK_TYPE, *PHTTP_DATA_CHUNK_TYPE; 222 223 #define HTTP_BYTE_RANGE_TO_EOF ((ULONGLONG)-1) 224 225 typedef struct _HTTP_BYTE_RANGE 226 { 227 ULARGE_INTEGER StartingOffset; 228 ULARGE_INTEGER Length; 229 } HTTP_BYTE_RANGE, *PHTTP_BYTE_RANGE; 230 231 typedef struct _HTTP_DATA_CHUNK 232 { 233 HTTP_DATA_CHUNK_TYPE DataChunkType; 234 __C89_NAMELESS union 235 { 236 struct 237 { 238 void *pBuffer; 239 ULONG BufferLength; 240 } FromMemory; 241 struct 242 { 243 HTTP_BYTE_RANGE ByteRange; 244 HANDLE FileHandle; 245 } FromFileHandle; 246 struct 247 { 248 USHORT FragmentNameLength; 249 const WCHAR *pFragmentName; 250 } FromFragmentCache; 251 } DUMMYUNIONNAME; 252 } HTTP_DATA_CHUNK, *PHTTP_DATA_CHUNK; 253 254 typedef struct _HTTP_SSL_CLIENT_CERT_INFO 255 { 256 ULONG CertFlags; 257 ULONG CertEncodedSize; 258 UCHAR *pCertEncoded; 259 HANDLE Token; 260 BOOLEAN CertDeniedByMapper; 261 } HTTP_SSL_CLIENT_CERT_INFO, *PHTTP_SSL_CLIENT_CERT_INFO; 262 263 typedef struct _HTTP_SSL_INFO 264 { 265 USHORT ServerCertKeySize; 266 USHORT ConnectionKeySize; 267 ULONG ServerCertIssuerSize; 268 ULONG ServerCertSubjectSize; 269 const char *pServerCertIssuer; 270 const char *pServerCertSubject; 271 HTTP_SSL_CLIENT_CERT_INFO *pClientCertInfo; 272 ULONG SslClientCertNegotiated; 273 } HTTP_SSL_INFO, *PHTTP_SSL_INFO; 274 275 typedef struct _HTTP_REQUEST_V1 276 { 277 ULONG Flags; 278 HTTP_CONNECTION_ID ConnectionId; 279 HTTP_REQUEST_ID RequestId; 280 HTTP_URL_CONTEXT UrlContext; 281 HTTP_VERSION Version; 282 HTTP_VERB Verb; 283 USHORT UnknownVerbLength; 284 USHORT RawUrlLength; 285 const char *pUnknownVerb; 286 const char *pRawUrl; 287 HTTP_COOKED_URL CookedUrl; 288 HTTP_TRANSPORT_ADDRESS Address; 289 HTTP_REQUEST_HEADERS Headers; 290 ULONGLONG BytesReceived; 291 USHORT EntityChunkCount; 292 HTTP_DATA_CHUNK *pEntityChunks; 293 HTTP_RAW_CONNECTION_ID RawConnectionId; 294 HTTP_SSL_INFO *pSslInfo; 295 } HTTP_REQUEST_V1; 296 297 typedef enum _HTTP_REQUEST_INFO_TYPE 298 { 299 HttpRequestInfoTypeAuth = 0, 300 } HTTP_REQUEST_INFO_TYPE, *PHTTP_REQUEST_INFO_TYPE; 301 302 typedef struct _HTTP_REQUEST_INFO 303 { 304 HTTP_REQUEST_INFO_TYPE InfoType; 305 ULONG InfoLength; 306 void *pInfo; 307 } HTTP_REQUEST_INFO, *PHTTP_REQUEST_INFO; 308 309 #ifdef __cplusplus 310 typedef struct _HTTP_REQUEST_V2 : HTTP_REQUEST_V1 311 { 312 USHORT RequestInfoCount; 313 HTTP_REQUEST_INFO *pRequestInfo; 314 } HTTP_REQUEST_V2, *PHTTP_REQUEST_V2; 315 #else 316 typedef struct _HTTP_REQUEST_V2 317 { 318 HTTP_REQUEST_V1 s; 319 USHORT RequestInfoCount; 320 HTTP_REQUEST_INFO *pRequestInfo; 321 } HTTP_REQUEST_V2, *PHTTP_REQUEST_V2; 322 #endif 323 324 typedef HTTP_REQUEST_V2 HTTP_REQUEST, *PHTTP_REQUEST; 325 326 typedef struct _HTTP_RESPONSE_HEADERS 327 { 328 USHORT UnknownHeaderCount; 329 HTTP_UNKNOWN_HEADER *pUnknownHeaders; 330 USHORT TrailerCount; 331 HTTP_UNKNOWN_HEADER *pTrailers; 332 HTTP_KNOWN_HEADER KnownHeaders[HttpHeaderResponseMaximum]; 333 } HTTP_RESPONSE_HEADERS,*PHTTP_RESPONSE_HEADERS; 334 335 typedef struct _HTTP_RESPONSE_V1 336 { 337 ULONG Flags; 338 HTTP_VERSION Version; 339 USHORT StatusCode; 340 USHORT ReasonLength; 341 const char *pReason; 342 HTTP_RESPONSE_HEADERS Headers; 343 USHORT EntityChunkCount; 344 HTTP_DATA_CHUNK *pEntityChunks; 345 } HTTP_RESPONSE_V1, *PHTTP_RESPONSE_V1; 346 347 typedef enum _HTTP_RESPONSE_INFO_TYPE 348 { 349 HttpResponseInfoTypeMultipleKnownHeaders = 0, 350 HttpResponseInfoTypeAuthenticationProperty, 351 HttpResponseInfoTypeQosProperty, 352 HttpResponseInfoTypeChannelBind, 353 } HTTP_RESPONSE_INFO_TYPE, *PHTTP_RESPONSE_INFO_TYPE; 354 355 typedef struct _HTTP_RESPONSE_INFO 356 { 357 HTTP_RESPONSE_INFO_TYPE Type; 358 ULONG Length; 359 void *pInfo; 360 } HTTP_RESPONSE_INFO, *PHTTP_RESPONSE_INFO; 361 362 #ifdef __cplusplus 363 typedef struct _HTTP_RESPONSE_V2 : HTTP_RESPONSE_V1 364 { 365 USHORT ResponseInfoCount; 366 HTTP_RESPONSE_INFO *pResponseInfo; 367 } HTTP_RESPONSE_V2, *PHTTP_RESPONSE_V2; 368 #else 369 typedef struct _HTTP_RESPONSE_V2 370 { 371 HTTP_RESPONSE_V1 s; 372 USHORT ResponseInfoCount; 373 HTTP_RESPONSE_INFO *pResponseInfo; 374 } HTTP_RESPONSE_V2, *PHTTP_RESPONSE_V2; 375 #endif 376 377 typedef HTTP_RESPONSE_V2 HTTP_RESPONSE, *PHTTP_RESPONSE; 378 379 typedef enum _HTTP_CACHE_POLICY_TYPE 380 { 381 HttpCachePolicyNocache, 382 HttpCachePolicyUserInvalidates, 383 HttpCachePolicyTimeToLive, 384 HttpCachePolicyMaximum, 385 } HTTP_CACHE_POLICY_TYPE, *PHTTP_CACHE_POLICY_TYPE; 386 387 typedef struct _HTTP_CACHE_POLICY 388 { 389 HTTP_CACHE_POLICY_TYPE Policy; 390 ULONG SecondsToLive; 391 } HTTP_CACHE_POLICY, *PHTTP_CACHE_POLICY; 392 393 typedef enum _HTTP_LOG_DATA_TYPE 394 { 395 HttpLogDataTypeFields = 0, 396 } HTTP_LOG_DATA_TYPE, *PHTTP_LOG_DATA_TYPE; 397 398 typedef struct _HTTP_LOG_DATA 399 { 400 HTTP_LOG_DATA_TYPE Type; 401 } HTTP_LOG_DATA, *PHTTP_LOG_DATA; 402 403 typedef enum _HTTP_SERVER_PROPERTY 404 { 405 HttpServerAuthenticationProperty, 406 HttpServerLoggingProperty, 407 HttpServerQosProperty, 408 HttpServerTimeoutsProperty, 409 HttpServerQueueLengthProperty, 410 HttpServerStateProperty, 411 HttpServer503VerbosityProperty, 412 HttpServerBindingProperty, 413 HttpServerExtendedAuthenticationProperty, 414 HttpServerListenEndpointProperty, 415 HttpServerChannelBindProperty, 416 HttpServerProtectionLevelProperty, 417 } HTTP_SERVER_PROPERTY, *PHTTP_SERVER_PROPERTY; 418 419 typedef struct _HTTP_PROPERTY_FLAGS 420 { 421 ULONG Present : 1; 422 } HTTP_PROPERTY_FLAGS, *PHTTP_PROPERTY_FLAGS; 423 424 typedef struct _HTTP_BINDING_INFO 425 { 426 HTTP_PROPERTY_FLAGS Flags; 427 HANDLE RequestQueueHandle; 428 } HTTP_BINDING_INFO, *PHTTP_BINDING_INFO; 429 430 ULONG WINAPI HttpAddUrl(HANDLE,PCWSTR,PVOID); 431 ULONG WINAPI HttpAddUrlToUrlGroup(HTTP_URL_GROUP_ID id, const WCHAR *url, HTTP_URL_CONTEXT context, ULONG reserved); 432 ULONG WINAPI HttpCloseRequestQueue(HANDLE handle); 433 ULONG WINAPI HttpCloseServerSession(HTTP_SERVER_SESSION_ID id); 434 ULONG WINAPI HttpCloseUrlGroup(HTTP_URL_GROUP_ID id); 435 ULONG WINAPI HttpCreateHttpHandle(PHANDLE,ULONG); 436 ULONG WINAPI HttpCreateRequestQueue(HTTPAPI_VERSION version, const WCHAR *name, SECURITY_ATTRIBUTES *sa, ULONG flags, HANDLE *handle); 437 ULONG WINAPI HttpCreateServerSession(HTTPAPI_VERSION,PHTTP_SERVER_SESSION_ID,ULONG); 438 ULONG WINAPI HttpCreateUrlGroup(HTTP_SERVER_SESSION_ID session_id, HTTP_URL_GROUP_ID *group_id, ULONG reserved); 439 ULONG WINAPI HttpDeleteServiceConfiguration(HANDLE,HTTP_SERVICE_CONFIG_ID,PVOID,ULONG,LPOVERLAPPED); 440 ULONG WINAPI HttpInitialize(HTTPAPI_VERSION version, ULONG flags, void *reserved); 441 ULONG WINAPI HttpTerminate(ULONG flags, void *reserved); 442 ULONG WINAPI HttpQueryServiceConfiguration(HANDLE,HTTP_SERVICE_CONFIG_ID,PVOID,ULONG,PVOID,ULONG,PULONG,LPOVERLAPPED); 443 ULONG WINAPI HttpReceiveHttpRequest(HANDLE queue, HTTP_REQUEST_ID id, ULONG flags, HTTP_REQUEST *request, ULONG size, ULONG *ret_size, OVERLAPPED *ovl); 444 ULONG WINAPI HttpRemoveUrl(HANDLE queue, const WCHAR *url); 445 ULONG WINAPI HttpRemoveUrlFromUrlGroup(HTTP_URL_GROUP_ID id, const WCHAR *url, ULONG flags); 446 ULONG WINAPI HttpSendHttpResponse(HANDLE queue, HTTP_REQUEST_ID id, ULONG flags, HTTP_RESPONSE *response, HTTP_CACHE_POLICY *cache_policy, ULONG *ret_size, void *reserved1, ULONG reserved2, OVERLAPPED *ovl, HTTP_LOG_DATA *log_data); 447 ULONG WINAPI HttpSetServiceConfiguration(HANDLE,HTTP_SERVICE_CONFIG_ID,PVOID,ULONG,LPOVERLAPPED); 448 ULONG WINAPI HttpSetUrlGroupProperty(HTTP_URL_GROUP_ID id, HTTP_SERVER_PROPERTY property, void *value, ULONG length); 449 450 #ifdef __cplusplus 451 } 452 #endif 453 454 #endif /* __WINE_HTTP_H */ 455