' PBXA64/PBXB64 declarations for Windows HTTP Server API (httpapi.dll/http.h).
#IF NOT %DEF(PBX_HTTPAPI_PBI)
#DEFINE PBX_HTTPAPI_PBI
#INCLUDE ONCE "Legacy/Platform/win_types.inc"
#INCLUDE ONCE "Legacy/Platform/win_consts.inc"

%EQUATE `HTTP_INITIALIZE_SERVER = &H00000001
%EQUATE `HTTP_INITIALIZE_CONFIG = &H00000002
%EQUATE `HTTPAPI_VERSION_1 = &H0001
%EQUATE `HTTPAPI_VERSION_2 = &H0002
%EQUATE `HTTP_RECEIVE_REQUEST_FLAG_COPY_BODY = &H00000001
%EQUATE `HTTP_RECEIVE_SECURE_CHANNEL_TOKEN = &H00000001
%EQUATE `HTTP_SEND_RESPONSE_FLAG_DISCONNECT = &H00000001
%EQUATE `HTTP_SEND_RESPONSE_FLAG_MORE_DATA = &H00000002
%EQUATE `HTTP_SEND_RESPONSE_FLAG_BUFFER_DATA = &H00000004
%EQUATE `HTTP_SEND_RESPONSE_FLAG_ENABLE_NAGLING = &H00000008
%EQUATE `HTTP_SEND_RESPONSE_FLAG_PROCESS_RANGES = &H00000020
%EQUATE `HTTP_SEND_RESPONSE_FLAG_OPAQUE = &H00000040
%EQUATE `HTTP_SEND_RESPONSE_FLAG_GOAWAY = &H00000100
%EQUATE `HTTP_NULL_ID = 0
%EQUATE `HTTP_AUTH_ENABLE_BASIC = &H00000001
%EQUATE `HTTP_AUTH_ENABLE_DIGEST = &H00000002
%EQUATE `HTTP_AUTH_ENABLE_NTLM = &H00000004
%EQUATE `HTTP_AUTH_ENABLE_NEGOTIATE = &H00000008
%EQUATE `HTTP_AUTH_ENABLE_KERBEROS = &H00000010

%EQUATE `HTTP_HEADER_ID_CACHE_CONTROL = 0
%EQUATE `HTTP_HEADER_ID_CONNECTION = 1
%EQUATE `HTTP_HEADER_ID_DATE = 2
%EQUATE `HTTP_HEADER_ID_KEEP_ALIVE = 3
%EQUATE `HTTP_HEADER_ID_PRAGMA = 4
%EQUATE `HTTP_HEADER_ID_TRAILER = 5
%EQUATE `HTTP_HEADER_ID_TRANSFER_ENCODING = 6
%EQUATE `HTTP_HEADER_ID_UPGRADE = 7
%EQUATE `HTTP_HEADER_ID_VIA = 8
%EQUATE `HTTP_HEADER_ID_WARNING = 9
%EQUATE `HTTP_HEADER_ID_ALLOW = 10
%EQUATE `HTTP_HEADER_ID_CONTENT_LENGTH = 11
%EQUATE `HTTP_HEADER_ID_CONTENT_TYPE = 12
%EQUATE `HTTP_HEADER_ID_CONTENT_ENCODING = 13
%EQUATE `HTTP_HEADER_ID_CONTENT_LANGUAGE = 14
%EQUATE `HTTP_HEADER_ID_CONTENT_LOCATION = 15
%EQUATE `HTTP_HEADER_ID_CONTENT_MD5 = 16
%EQUATE `HTTP_HEADER_ID_CONTENT_RANGE = 17
%EQUATE `HTTP_HEADER_ID_EXPIRES = 18
%EQUATE `HTTP_HEADER_ID_LAST_MODIFIED = 19
%EQUATE `HTTP_HEADER_ID_ACCEPT = 20
%EQUATE `HTTP_HEADER_ID_ACCEPT_CHARSET = 21
%EQUATE `HTTP_HEADER_ID_ACCEPT_ENCODING = 22
%EQUATE `HTTP_HEADER_ID_ACCEPT_LANGUAGE = 23
%EQUATE `HTTP_HEADER_ID_AUTHORIZATION = 24
%EQUATE `HTTP_HEADER_ID_COOKIE = 25
%EQUATE `HTTP_HEADER_ID_EXPECT = 26
%EQUATE `HTTP_HEADER_ID_FROM = 27
%EQUATE `HTTP_HEADER_ID_HOST = 28
%EQUATE `HTTP_HEADER_ID_IF_MATCH = 29
%EQUATE `HTTP_HEADER_ID_MAX = 40

%EQUATE `HTTP_DATA_CHUNK_FROM_MEMORY = 0
%EQUATE `HTTP_DATA_CHUNK_FROM_FILE_HANDLE = 1
%EQUATE `HTTP_DATA_CHUNK_FROM_FRAGMENT_CACHE = 2
%EQUATE `HTTP_DATA_CHUNK_FROM_FRAGMENT_CACHE_EX = 3
%EQUATE `HTTP_DATA_CHUNK_TRAILERS = 4

%EQUATE `HTTP_PROPERTY_SERVER_AUTHENTICATION = 0
%EQUATE `HTTP_PROPERTY_SERVER_LOGGING = 1
%EQUATE `HTTP_PROPERTY_SERVER_QOS = 2
%EQUATE `HTTP_PROPERTY_SERVER_TIMEOUTS = 3
%EQUATE `HTTP_PROPERTY_SERVER_QUEUE_LENGTH = 4
%EQUATE `HTTP_PROPERTY_SERVER_STATE = 5
%EQUATE `HTTP_PROPERTY_REQUEST_QUEUE_STATE = 0
%EQUATE `HTTP_PROPERTY_REQUEST_QUEUE_503_VERBOSITY = 1
%EQUATE `HTTP_PROPERTY_REQUEST_QUEUE_LENGTH = 2
%EQUATE `HTTP_PROPERTY_REQUEST_QUEUE_MODE = 3

TYPE HTTPAPI_VERSION
    HttpApiMajorVersion AS WORD
    HttpApiMinorVersion AS WORD
END TYPE

TYPE HTTP_VERSION
    MajorVersion AS WORD
    MinorVersion AS WORD
END TYPE

TYPE HTTP_KNOWN_HEADER
    RawValueLength AS WORD
    pRawValue AS QUAD
END TYPE

TYPE HTTP_UNKNOWN_HEADER
    NameLength AS WORD
    RawValueLength AS WORD
    pName AS QUAD
    pRawValue AS QUAD
END TYPE

TYPE PBX_HTTP_KNOWN_HEADER30
    h00 AS HTTP_KNOWN_HEADER
    h01 AS HTTP_KNOWN_HEADER
    h02 AS HTTP_KNOWN_HEADER
    h03 AS HTTP_KNOWN_HEADER
    h04 AS HTTP_KNOWN_HEADER
    h05 AS HTTP_KNOWN_HEADER
    h06 AS HTTP_KNOWN_HEADER
    h07 AS HTTP_KNOWN_HEADER
    h08 AS HTTP_KNOWN_HEADER
    h09 AS HTTP_KNOWN_HEADER
    h10 AS HTTP_KNOWN_HEADER
    h11 AS HTTP_KNOWN_HEADER
    h12 AS HTTP_KNOWN_HEADER
    h13 AS HTTP_KNOWN_HEADER
    h14 AS HTTP_KNOWN_HEADER
    h15 AS HTTP_KNOWN_HEADER
    h16 AS HTTP_KNOWN_HEADER
    h17 AS HTTP_KNOWN_HEADER
    h18 AS HTTP_KNOWN_HEADER
    h19 AS HTTP_KNOWN_HEADER
    h20 AS HTTP_KNOWN_HEADER
    h21 AS HTTP_KNOWN_HEADER
    h22 AS HTTP_KNOWN_HEADER
    h23 AS HTTP_KNOWN_HEADER
    h24 AS HTTP_KNOWN_HEADER
    h25 AS HTTP_KNOWN_HEADER
    h26 AS HTTP_KNOWN_HEADER
    h27 AS HTTP_KNOWN_HEADER
    h28 AS HTTP_KNOWN_HEADER
    h29 AS HTTP_KNOWN_HEADER
END TYPE

TYPE HTTP_REQUEST_HEADERS
    UnknownHeaderCount AS WORD
    pUnknownHeaders AS QUAD
    TrailerCount AS WORD
    pTrailers AS QUAD
    KnownHeaders AS PBX_HTTP_KNOWN_HEADER30
END TYPE

TYPE HTTP_RESPONSE_HEADERS
    UnknownHeaderCount AS WORD
    pUnknownHeaders AS QUAD
    TrailerCount AS WORD
    pTrailers AS QUAD
    KnownHeaders AS PBX_HTTP_KNOWN_HEADER30
END TYPE

TYPE HTTP_DATA_CHUNK
    DataChunkType AS LONG
    pBuffer AS QUAD
    BufferLength AS DWORD
    Reserved01 AS QUAD
    Reserved02 AS QUAD
END TYPE

TYPE HTTP_RESPONSE_V1
    Flags AS DWORD
    VersionInfo AS HTTP_VERSION
    StatusCode AS WORD
    ReasonLength AS WORD
    pReason AS QUAD
    Headers AS HTTP_RESPONSE_HEADERS
    EntityChunkCount AS WORD
    pEntityChunks AS QUAD
END TYPE

TYPE HTTP_REQUEST_V1_MIN
    Flags AS DWORD
    ConnectionId AS QUAD
    RequestId AS QUAD
    UrlContext AS QUAD
    VersionInfo AS HTTP_VERSION
    Verb AS LONG
    UnknownVerbLength AS WORD
    RawUrlLength AS WORD
    pUnknownVerb AS QUAD
    pRawUrl AS QUAD
    CookedUrl AS PBX_BYTE64
    Address AS PBX_BYTE32
    Headers AS HTTP_REQUEST_HEADERS
    BytesReceived AS QUAD
    EntityChunkCount AS WORD
    pEntityChunks AS QUAD
    RawConnectionId AS QUAD
    pSslInfo AS QUAD
END TYPE

DECLARE FUNCTION HttpInitialize LIB "httpapi.dll" ALIAS "HttpInitialize" (BYVAL VersionInfo AS DWORD, BYVAL Flags AS DWORD, BYVAL pReserved AS QUAD) AS DWORD
DECLARE FUNCTION HttpTerminate LIB "httpapi.dll" ALIAS "HttpTerminate" (BYVAL Flags AS DWORD, BYVAL pReserved AS QUAD) AS DWORD
DECLARE FUNCTION HttpCreateHttpHandle LIB "httpapi.dll" ALIAS "HttpCreateHttpHandle" (BYVAL pReqQueueHandle AS QUAD, BYVAL Reserved AS DWORD) AS DWORD
DECLARE FUNCTION HttpCloseRequestQueue LIB "httpapi.dll" ALIAS "HttpCloseRequestQueue" (BYVAL ReqQueueHandle AS QUAD) AS DWORD
DECLARE FUNCTION HttpAddUrlA LIB "httpapi.dll" ALIAS "HttpAddUrlA" (BYVAL ReqQueueHandle AS QUAD, BYVAL pFullyQualifiedUrl AS ASCIIZ PTR, BYVAL pReserved AS QUAD) AS DWORD
DECLARE FUNCTION HttpAddUrlW LIB "httpapi.dll" ALIAS "HttpAddUrl" (BYVAL ReqQueueHandle AS QUAD, BYVAL pFullyQualifiedUrl AS WSTRING, BYVAL pReserved AS QUAD) AS DWORD
DECLARE FUNCTION HttpRemoveUrlA LIB "httpapi.dll" ALIAS "HttpRemoveUrlA" (BYVAL ReqQueueHandle AS QUAD, BYVAL pFullyQualifiedUrl AS ASCIIZ PTR) AS DWORD
DECLARE FUNCTION HttpRemoveUrlW LIB "httpapi.dll" ALIAS "HttpRemoveUrl" (BYVAL ReqQueueHandle AS QUAD, BYVAL pFullyQualifiedUrl AS WSTRING) AS DWORD
DECLARE FUNCTION HttpReceiveHttpRequest LIB "httpapi.dll" ALIAS "HttpReceiveHttpRequest" (BYVAL ReqQueueHandle AS QUAD, BYVAL RequestId AS QUAD, BYVAL Flags AS DWORD, BYVAL pRequestBuffer AS QUAD, BYVAL RequestBufferLength AS DWORD, BYVAL pBytesReceived AS QUAD, BYVAL pOverlapped AS QUAD) AS DWORD
DECLARE FUNCTION HttpReceiveRequestEntityBody LIB "httpapi.dll" ALIAS "HttpReceiveRequestEntityBody" (BYVAL ReqQueueHandle AS QUAD, BYVAL RequestId AS QUAD, BYVAL Flags AS DWORD, BYVAL pBuffer AS QUAD, BYVAL BufferLength AS DWORD, BYVAL pBytesReceived AS QUAD, BYVAL pOverlapped AS QUAD) AS DWORD
DECLARE FUNCTION HttpSendHttpResponse LIB "httpapi.dll" ALIAS "HttpSendHttpResponse" (BYVAL ReqQueueHandle AS QUAD, BYVAL RequestId AS QUAD, BYVAL Flags AS DWORD, BYVAL pHttpResponse AS QUAD, BYVAL pCachePolicy AS QUAD, BYVAL pBytesSent AS QUAD, BYVAL pReserved1 AS QUAD, BYVAL Reserved2 AS DWORD, BYVAL pOverlapped AS QUAD, BYVAL pLogData AS QUAD) AS DWORD
DECLARE FUNCTION HttpSendResponseEntityBody LIB "httpapi.dll" ALIAS "HttpSendResponseEntityBody" (BYVAL ReqQueueHandle AS QUAD, BYVAL RequestId AS QUAD, BYVAL Flags AS DWORD, BYVAL EntityChunkCount AS WORD, BYVAL pEntityChunks AS QUAD, BYVAL pBytesSent AS QUAD, BYVAL pReserved1 AS QUAD, BYVAL Reserved2 AS DWORD, BYVAL pOverlapped AS QUAD, BYVAL pLogData AS QUAD) AS DWORD
DECLARE FUNCTION HttpCancelHttpRequest LIB "httpapi.dll" ALIAS "HttpCancelHttpRequest" (BYVAL ReqQueueHandle AS QUAD, BYVAL RequestId AS QUAD, BYVAL pOverlapped AS QUAD) AS DWORD
DECLARE FUNCTION HttpWaitForDisconnect LIB "httpapi.dll" ALIAS "HttpWaitForDisconnect" (BYVAL ReqQueueHandle AS QUAD, BYVAL ConnectionId AS QUAD, BYVAL pOverlapped AS QUAD) AS DWORD
DECLARE FUNCTION HttpFlushResponseCache LIB "httpapi.dll" ALIAS "HttpFlushResponseCache" (BYVAL ReqQueueHandle AS QUAD, BYVAL UrlPrefix AS WSTRING, BYVAL Flags AS DWORD, BYVAL pOverlapped AS QUAD) AS DWORD
DECLARE FUNCTION HttpCreateServerSession LIB "httpapi.dll" ALIAS "HttpCreateServerSession" (BYVAL VersionInfo AS DWORD, BYVAL pServerSessionId AS QUAD, BYVAL Reserved AS DWORD) AS DWORD
DECLARE FUNCTION HttpCloseServerSession LIB "httpapi.dll" ALIAS "HttpCloseServerSession" (BYVAL ServerSessionId AS QUAD) AS DWORD
DECLARE FUNCTION HttpCreateUrlGroup LIB "httpapi.dll" ALIAS "HttpCreateUrlGroup" (BYVAL ServerSessionId AS QUAD, BYVAL pUrlGroupId AS QUAD, BYVAL Reserved AS DWORD) AS DWORD
DECLARE FUNCTION HttpCloseUrlGroup LIB "httpapi.dll" ALIAS "HttpCloseUrlGroup" (BYVAL UrlGroupId AS QUAD) AS DWORD
DECLARE FUNCTION HttpAddUrlToUrlGroup LIB "httpapi.dll" ALIAS "HttpAddUrlToUrlGroup" (BYVAL UrlGroupId AS QUAD, BYVAL pFullyQualifiedUrl AS WSTRING, BYVAL UrlContext AS QUAD, BYVAL Reserved AS DWORD) AS DWORD
DECLARE FUNCTION HttpRemoveUrlFromUrlGroup LIB "httpapi.dll" ALIAS "HttpRemoveUrlFromUrlGroup" (BYVAL UrlGroupId AS QUAD, BYVAL pFullyQualifiedUrl AS WSTRING, BYVAL Flags AS DWORD) AS DWORD
DECLARE FUNCTION HttpPrepareUrl LIB "httpapi.dll" ALIAS "HttpPrepareUrl" (BYVAL pReserved AS QUAD, BYVAL Flags AS DWORD, BYVAL Url AS WSTRING, BYVAL ppPreparedUrl AS QUAD) AS DWORD
DECLARE FUNCTION HttpSetRequestQueueProperty LIB "httpapi.dll" ALIAS "HttpSetRequestQueueProperty" (BYVAL ReqQueueHandle AS QUAD, BYVAL Property AS LONG, BYVAL pPropertyInformation AS QUAD, BYVAL PropertyInformationLength AS DWORD, BYVAL Reserved1 AS DWORD, BYVAL pReserved2 AS QUAD) AS DWORD
DECLARE FUNCTION HttpQueryRequestQueueProperty LIB "httpapi.dll" ALIAS "HttpQueryRequestQueueProperty" (BYVAL ReqQueueHandle AS QUAD, BYVAL Property AS LONG, BYVAL pPropertyInformation AS QUAD, BYVAL PropertyInformationLength AS DWORD, BYVAL Reserved1 AS DWORD, BYVAL pReturnLength AS QUAD, BYVAL pReserved2 AS QUAD) AS DWORD

#ENDIF
