using System.Threading;
using static Vanara.PInvoke.Kernel32;
namespace Vanara.PInvoke;
public static partial class HttpApi
{
/// The HTTP_IS_NULL_ID macro determines if the HTTP_OPAQUE_ID is NULL.
/// The parameter determined to be NULL.
/// None
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-http_is_null_id void HTTP_IS_NULL_ID( pid );
[PInvokeData("http.h", MSDNShortId = "NF:http.HTTP_IS_NULL_ID")]
public static bool HTTP_IS_NULL_ID(HTTP_OPAQUE_ID pid) => pid == HTTP_NULL_ID;
///
/// The HttpAddFragmentToCache function caches a data fragment with a specified name by which it can be retrieved, or updates data
/// cached under a specified name. Such cached data fragments can be used repeatedly to construct dynamic responses without the expense
/// of disk reads. For example, a response composed of text and three images could be assembled dynamically from four or more cached
/// fragments at the time a request is processed.
///
///
///
/// Handle to the request queue with which this cache is associated. A request queue is created and its handle returned by a call to the
/// HttpCreateRequestQueue function.
///
///
/// Windows Server 2003 with SP1 and Windows XP with SP2: The handle to the request queue is created by the HttpCreateHttpHandle function.
///
///
///
///
/// Pointer to a UrlPrefix string that the application uses in subsequent calls to HttpSendHttpResponse to identify this cache entry. The
/// application must have called HttpAddUrl previously with the same handle as in the ReqQueueHandle parameter, and with
/// either this identical UrlPrefix string or a valid prefix of it.
///
/// Like any UrlPrefix, this string must take the form "scheme://host:port/relativeURI"; for example, http://www.mysite.com:80/image1.gif.
///
///
/// Pointer to an HTTP_DATA_CHUNK structure that specifies an entity body data block to cache under the name pointed to by pUrlPrefix.
///
/// Pointer to an HTTP_CACHE_POLICY structure that specifies how this data fragment should be cached.
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure, or for synchronous calls, set it to NULL.
///
/// A synchronous call blocks the calling thread until the cache operation is complete, whereas an asynchronous call immediately returns
/// ERROR_IO_PENDING and the calling application then uses GetOverlappedResult or I/O completion ports to determine when the operation is
/// completed. For more information about using OVERLAPPED structures for synchronization, see Synchronization and Overlapped Input and Output.
///
///
///
/// If the function succeeds, the return value is NO_ERROR.
///
/// If the function is used asynchronously, a return value of ERROR_IO_PENDING indicates that the cache request is queued and will
/// complete later through normal overlapped I/O completion mechanisms.
///
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters is in an unusable form.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpaddfragmenttocache HTTPAPI_LINKAGE ULONG HttpAddFragmentToCache(
// [in] HANDLE RequestQueueHandle, [in] PCWSTR UrlPrefix, [in] PHTTP_DATA_CHUNK DataChunk, [in] PHTTP_CACHE_POLICY CachePolicy, [in,
// optional] LPOVERLAPPED Overlapped );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpAddFragmentToCache")]
public static extern uint HttpAddFragmentToCache(HREQQUEUEv1 RequestQueueHandle, [MarshalAs(UnmanagedType.LPWStr)] string UrlPrefix,
in HTTP_DATA_CHUNK DataChunk, in HTTP_CACHE_POLICY CachePolicy, [In, Optional] IntPtr Overlapped);
///
/// The HttpAddFragmentToCache function caches a data fragment with a specified name by which it can be retrieved, or updates data
/// cached under a specified name. Such cached data fragments can be used repeatedly to construct dynamic responses without the expense
/// of disk reads. For example, a response composed of text and three images could be assembled dynamically from four or more cached
/// fragments at the time a request is processed.
///
///
///
/// Handle to the request queue with which this cache is associated. A request queue is created and its handle returned by a call to the
/// HttpCreateRequestQueue function.
///
///
/// Windows Server 2003 with SP1 and Windows XP with SP2: The handle to the request queue is created by the HttpCreateHttpHandle function.
///
///
///
///
/// Pointer to a UrlPrefix string that the application uses in subsequent calls to HttpSendHttpResponse to identify this cache entry. The
/// application must have called HttpAddUrl previously with the same handle as in the ReqQueueHandle parameter, and with
/// either this identical UrlPrefix string or a valid prefix of it.
///
/// Like any UrlPrefix, this string must take the form "scheme://host:port/relativeURI"; for example, http://www.mysite.com:80/image1.gif.
///
///
/// Pointer to an HTTP_DATA_CHUNK structure that specifies an entity body data block to cache under the name pointed to by pUrlPrefix.
///
/// Pointer to an HTTP_CACHE_POLICY structure that specifies how this data fragment should be cached.
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure, or for synchronous calls, set it to NULL.
///
/// A synchronous call blocks the calling thread until the cache operation is complete, whereas an asynchronous call immediately returns
/// ERROR_IO_PENDING and the calling application then uses GetOverlappedResult or I/O completion ports to determine when the operation is
/// completed. For more information about using OVERLAPPED structures for synchronization, see Synchronization and Overlapped Input and Output.
///
///
///
/// If the function succeeds, the return value is NO_ERROR.
///
/// If the function is used asynchronously, a return value of ERROR_IO_PENDING indicates that the cache request is queued and will
/// complete later through normal overlapped I/O completion mechanisms.
///
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters is in an unusable form.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpaddfragmenttocache HTTPAPI_LINKAGE ULONG HttpAddFragmentToCache(
// [in] HANDLE RequestQueueHandle, [in] PCWSTR UrlPrefix, [in] PHTTP_DATA_CHUNK DataChunk, [in] PHTTP_CACHE_POLICY CachePolicy, [in,
// optional] LPOVERLAPPED Overlapped );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpAddFragmentToCache")]
public static extern Win32Error HttpAddFragmentToCache(HREQQUEUE RequestQueueHandle, [MarshalAs(UnmanagedType.LPWStr)] string UrlPrefix,
in HTTP_DATA_CHUNK DataChunk, in HTTP_CACHE_POLICY CachePolicy, in NativeOverlapped Overlapped);
///
///
/// The HttpAddUrl function registers a given URL so that requests that match it are routed to a specified HTTP Server API request
/// queue. An application can register multiple URLs to a single request queue using repeated calls to HttpAddUrl. For more
/// information about how HTTP Server API matches request URLs to registered URLs, see UrlPrefix Strings.
///
///
/// Starting with HTTP Server API Version 2.0, applications should call HttpAddUrlToUrlGroup to register a URL; HttpAddUrl should
/// not be used.
///
///
///
///
/// The handle to the request queue to which requests for the specified URL are to be routed. A request queue is created and its handle
/// returned by a call to the HttpCreateRequestQueue function.
///
///
/// Windows Server 2003 with SP1 and Windows XP with SP2: The handle to the request queue is created by the HttpCreateHttpHandle function.
///
///
///
/// A pointer to a Unicode string that contains a properly formed UrlPrefix string that identifies the URL to be registered.
///
/// Reserved; must be NULL.
///
/// If the function succeeds, the return value is NO_ERROR.
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_ACCESS_DENIED
/// The calling application does not have permission to register the URL.
///
/// -
/// ERROR_DLL_INIT_FAILED
/// The calling application did not call HttpInitialize before calling this function.
///
/// -
/// ERROR_INVALID_PARAMETER
/// One of the parameters are invalid.
///
/// -
/// ERROR_ALREADY_EXISTS
/// The specified UrlPrefix conflicts with an existing registration.
///
/// -
/// ERROR_NOT_ENOUGH_MEMORY
/// Insufficient resources to complete the operation.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
///
///
/// As stated in the UrlPrefix Strings topic, the scheme specification of the UrlPrefix to be registered must be either lower-case "http"
/// or lower-case "https". No other substring is valid.
///
///
/// Also, it is not possible to register URLs having different schemes on the same port. That is, "http" and "https" schemes cannot
/// coexist on a port.
///
///
/// Also be aware that HttpAddUrl registers any UrlPrefix passed to it as long as the string is well-formed. Any validation of
/// existence, accessibility, ownership, or other characteristic of the specified URL namespace must be handled by the application.
///
///
/// To release the resources allocated as a result of the registration performed by HttpAddUrl, make a matching call to the
/// HttpRemoveUrl function when your application has finished with the namespace involved.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpaddurl HTTPAPI_LINKAGE ULONG HttpAddUrl( [in] HANDLE
// RequestQueueHandle, [in] PCWSTR FullyQualifiedUrl, PVOID Reserved );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpAddUrl")]
public static extern Win32Error HttpAddUrl(HREQQUEUEv1 RequestQueueHandle, [MarshalAs(UnmanagedType.LPWStr)] string FullyQualifiedUrl, IntPtr Reserved = default);
///
/// The HttpAddUrlToUrlGroup function adds the specified URL to the URL Group identified by the URL Group ID.
/// This function replaces the HTTP version 1.0 HttpAddUrl function.
///
///
/// The group ID for the URL group to which requests for the specified URL are routed. The URL group is created by the HttpCreateUrlGroup function.
///
///
/// A pointer to a Unicode string that contains a properly formed UrlPrefix String that identifies the URL to be registered.
///
///
/// The context that is associated with the URL registered in this call. The URL context is returned in the HTTP_REQUEST structure with
/// every request received on the URL specified in the pFullyQualifiedUrl parameter.
///
/// Reserved. Must be zero.
///
/// If the function succeeds, it returns NO_ERROR
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
///
/// The UrlGroupId does not exist. The Reserved parameter is not zero. The application does not have permission to add URLs
/// to the Group. Only the application that created the URL Group can add URLs.
///
///
/// -
/// ERROR_ACCESS_DENIED
/// The calling process does not have permission to register the URL.
///
/// -
/// ERROR_ALREADY_EXISTS
/// The specified URL conflicts with an existing registration.
///
///
///
///
///
/// The HTTP Server API supports existing applications using version 1.0 URL registrations, however, new development with the HTTP Server
/// API should use HttpAddUrlToUrlGroup; HttpAddUrl should not be used.
///
///
/// An application can add multiple URLs to a URL group using repeated calls to HttpAddUrlToUrlGroup. Requests that match the
/// specified URL are routed to the request queue associated with the URL group. For more information about how the HTTP Server API
/// matches request URLs to registered URLs, see UrlPrefix Strings.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpaddurltourlgroup HTTPAPI_LINKAGE ULONG HttpAddUrlToUrlGroup( [in]
// HTTP_URL_GROUP_ID UrlGroupId, [in] PCWSTR pFullyQualifiedUrl, [in, optional] HTTP_URL_CONTEXT UrlContext, [in] ULONG Reserved );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpAddUrlToUrlGroup")]
public static extern Win32Error HttpAddUrlToUrlGroup([In] HTTP_URL_GROUP_ID UrlGroupId, [MarshalAs(UnmanagedType.LPWStr)] string pFullyQualifiedUrl,
[In, Optional] HTTP_URL_CONTEXT UrlContext, uint Reserved = 0);
/// The HttpCancelHttpRequest function cancels a specified request.
/// A handle to the request queue from which the request came.
/// The ID of the request to be canceled.
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure; for synchronous calls, set it to NULL.
///
/// If the function succeeds, it returns NO_ERROR.
///
/// When the HttpCancelHttpRequest function is used to cancel a request, the underlying transport connection used for the request
/// will be closed.
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpcancelhttprequest HTTPAPI_LINKAGE ULONG HttpCancelHttpRequest(
// [in] HANDLE RequestQueueHandle, [in] HTTP_REQUEST_ID RequestId, [in, optional] LPOVERLAPPED Overlapped );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpCancelHttpRequest")]
public static extern Win32Error HttpCancelHttpRequest([In] HREQQUEUE RequestQueueHandle, [In] HTTP_REQUEST_ID RequestId, in NativeOverlapped Overlapped);
/// The HttpCancelHttpRequest function cancels a specified request.
/// A handle to the request queue from which the request came.
/// The ID of the request to be canceled.
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure; for synchronous calls, set it to NULL.
///
/// If the function succeeds, it returns NO_ERROR.
///
/// When the HttpCancelHttpRequest function is used to cancel a request, the underlying transport connection used for the request
/// will be closed.
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpcancelhttprequest HTTPAPI_LINKAGE ULONG HttpCancelHttpRequest(
// [in] HANDLE RequestQueueHandle, [in] HTTP_REQUEST_ID RequestId, [in, optional] LPOVERLAPPED Overlapped );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpCancelHttpRequest")]
public static extern Win32Error HttpCancelHttpRequest([In] HREQQUEUE RequestQueueHandle, [In] HTTP_REQUEST_ID RequestId, [In, Optional] IntPtr Overlapped);
///
/// The HttpCloseRequestQueue function closes the handle to the specified request queue created by HttpCreateRequestQueue.
/// The application must close the request queue when it is no longer required.
///
///
/// The handle to the request queue that is closed. A request queue is created and its handle returned by a call to the
/// HttpCreateRequestQueue function.
///
///
/// If the function succeeds, it returns NO_ERROR.
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
///
/// The application does not have permission to close the request queue. Only the application that created the request queue can close it.
///
///
///
///
///
/// Applications should not call CloseHandle on the request queue handle; instead, they should call HttpCloseRequestQueue to
/// ensure that all the resources are released.
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpcloserequestqueue HTTPAPI_LINKAGE ULONG HttpCloseRequestQueue(
// [in] HANDLE RequestQueueHandle );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpCloseRequestQueue")]
public static extern Win32Error HttpCloseRequestQueue(HREQQUEUE RequestQueueHandle);
///
/// The HttpCloseServerSession function deletes the server session identified by the server session ID. All remaining URL Groups
/// associated with the server session will also be closed.
///
/// The ID of the server session that is closed.
///
/// If the function succeeds, it returns NO_ERROR
/// If the function fails, it can return one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
///
/// The Server Session does not exist. The application does not have permission to close the server session. Only the application that
/// created the server session can close the session.
///
///
///
///
///
/// Applications must call HttpCloseUrlGroup before calling HttpCloseServerSession to close the all the URL Groups associated with
/// the server session.
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpcloseserversession HTTPAPI_LINKAGE ULONG HttpCloseServerSession(
// [in] HTTP_SERVER_SESSION_ID ServerSessionId );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpCloseServerSession")]
public static extern Win32Error HttpCloseServerSession(HTTP_SERVER_SESSION_ID ServerSessionId);
///
/// The HttpCloseUrlGroup function closes the URL Group identified by the URL Group ID. This call also removes all of the URLs
/// that are associated with the URL Group.
///
/// The ID of the URL Group that is deleted.
///
/// If the function succeeds, it returns NO_ERROR.
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
///
/// The ID of the URL Group does not exist. The application does not have permission to close the URL Group. Only the application that
/// created the URL Group can close the group.
///
///
///
///
///
/// Applications must call HttpCloseUrlGroup before calling HttpCloseServerSession to close the all URL Groups associated with the
/// server session.
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpcloseurlgroup HTTPAPI_LINKAGE ULONG HttpCloseUrlGroup( [in]
// HTTP_URL_GROUP_ID UrlGroupId );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpCloseUrlGroup")]
public static extern Win32Error HttpCloseUrlGroup(HTTP_URL_GROUP_ID UrlGroupId);
///
///
/// The HttpCreateHttpHandle function creates an HTTP request queue for the calling application and returns a handle to it.
///
///
/// Starting with HTTP Server API Version 2.0, applications should call HttpCreateRequestQueue to create the request queue;
/// HttpCreateHttpHandle should not be used.
///
///
/// A pointer to a variable that receives a handle to the request queue.
/// Reserved. This parameter must be zero.
///
/// If the function succeeds, the return value is NO_ERROR.
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_DLL_INIT_FAILED
/// The calling application did not call HttpInitialize before calling this function.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
///
///
/// The request queue enables the calling application to receive requests for particular URLs. The calling application uses the
/// HttpAddUrl function to specify the URL for which it should receive requests.
///
///
/// An application should use a single request queue to receive requests. Using multiple request queues from a single process does not
/// increase response time or throughput.
///
/// When an application has finished receiving requests, it should call the CloseHandle function to close the handle.
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpcreatehttphandle HTTPAPI_LINKAGE ULONG HttpCreateHttpHandle( [out]
// PHANDLE RequestQueueHandle, [in] ULONG Reserved );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpCreateHttpHandle")]
public static extern Win32Error HttpCreateHttpHandle(out SafeHREQQUEUEv1 RequestQueueHandle, uint Reserved = 0);
///
/// The HttpCreateRequestQueue function creates a new request queue or opens an existing request queue.
/// This function replaces the HTTP version 1.0 HttpCreateHttpHandle function.
///
///
///
/// An HTTPAPI_VERSION structure indicating the request queue version. For version 2.0, declare an instance of the structure and set it
/// to the predefined value HTTPAPI_VERSION_2 before passing it to HttpCreateRequestQueue.
///
/// The version must be 2.0; HttpCreateRequestQueue does not support version 1.0 request queues.
///
///
/// The name of the request queue. The length, in bytes, cannot exceed MAX_PATH.
/// The optional name parameter allows other processes to access the request queue by name.
///
///
/// A pointer to the SECURITY_ATTRIBUTES structure that contains the access permissions for the request queue.
/// This parameter must be NULL when opening an existing request queue.
///
///
/// The flags parameter defines the scope of the request queue. This parameter can be one or more of the following:
///
///
/// Value
/// Meaning
///
/// -
/// HTTP_CREATE_REQUEST_QUEUE_FLAG_CONTROLLER
///
/// The handle to the request queue created using this flag cannot be used to perform I/O operations. This flag can be set only when the
/// request queue handle is created.
///
///
/// -
/// HTTP_CREATE_REQUEST_QUEUE_FLAG_OPEN_EXISTING
///
/// The HTTP_CREATE_REQUEST_QUEUE_FLAG_OPEN_EXISTING flag allows applications to open an existing request queue by name and
/// retrieve the request queue handle. The pName parameter must contain a valid request queue name; it cannot be NULL.
///
///
///
///
///
/// A pointer to a variable that receives a handle to the request queue. This parameter must contain a valid pointer; it cannot be NULL.
///
///
/// If the function succeeds, it returns NO_ERROR
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_REVISION_MISMATCH
/// The Version parameter contains an invalid version.
///
/// -
/// ERROR_INVALID_PARAMETER
///
/// The length, in bytes, of the request queue name cannot exceed MAX_PATH. The pSecurityAttributes parameter must be NULL
/// when opening an existing request queue. The HTTP_CREATE_REQUEST_QUEUE_FLAG_CONTROLLER can only be set when the request queue
/// is created. The HTTP_CREATE_REQUEST_QUEUE_FLAG_OPEN_EXISTING can only be set when the application has permission to open an
/// existing request queue. In this case, the pReqQueueHandle parameter must be a valid pointer, and the pName parameter
/// must contain a valid request queue name; it cannot be NULL. The pReqQueueHandle parameter returned by
/// HttpCreateRequestQueue is NULL.
///
///
/// -
/// ERROR_ALREADY_EXISTS
/// The pName parameter conflicts with an existing request queue that contains an identical name.
///
/// -
/// ERROR_ACCESS_DENIED
/// The calling process does not have a permission to open the request queue.
///
/// -
/// ERROR_DLL_INIT_FAILED
/// The application has not called HttpInitialize prior to calling HttpCreateRequestQueue.
///
///
///
///
///
/// The HTTP Server API supports existing applications using the version 1.0 request queues, however, new development with the HTTP
/// Server API should use HttpCreateRequestQueue to create request queues; HttpCreateHttpHandle should not be used. The version
/// 2.0 API are only compatible with the version 2.0 request queues created by HttpCreateRequestQueue.
///
///
/// The HTTP version 2 request queues require manual configuration; the application must create the URL Groups and associate one or more
/// URL Group with the request queue by calling HttpSetUrlGroupProperty with the HttpServerBindingProperty. The application
/// configures the request queue by calling HttpSetRequestQueueProperty with the desired configuration in the Property parameter.
/// For more information about creating and configuring URL groups, see HttpCreateUrlGroup and HttpSetUrlGroupProperty.
///
///
/// Security attributes may be supplied in pSecurityAttributes parameter only when the request queue is created. Only the
/// application that creates the request queue can set Access Control Lists (ACLs) on the request queue handle to allow processes (other
/// than the creator application) permission to open, receive requests, and send responses on the request queue handle. By default,
/// applications are not allowed to open a request queue unless they have been granted permission in the ACL.
///
///
/// The creator process can optionally use the HTTP_CREATE_REQUEST_QUEUE_FLAG_CONTROLLER flag to indicate that it does not want to
/// receive http requests.
///
///
/// HttpCreateRequestQueue allows applications to open an existing request queue with the
/// HTTP_CREATE_REQUEST_QUEUE_FLAG_OPEN_EXISTING flag and retrieve the handle to the request queue. Non-controller applications
/// can use this handle to perform HTTP I/O operations. Only the application that creates the request queue can set properties on it by
/// calling the HttpSetRequestQueueProperty.
///
///
/// The handle to the request queue created by HttpCreateRequestQueue must be closed by calling HttpCloseRequestQueue before the
/// application terminates or when the session is no longer required.
///
/// Applications must call HttpInitialize prior to calling HttpCreateRequestQueue.
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpcreaterequestqueue HTTPAPI_LINKAGE ULONG HttpCreateRequestQueue(
// [in] HTTPAPI_VERSION Version, [in, optional] PCWSTR Name, [in, optional] PSECURITY_ATTRIBUTES SecurityAttributes, [in, optional] ULONG
// Flags, [out] PHANDLE RequestQueueHandle );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpCreateRequestQueue")]
public static extern Win32Error HttpCreateRequestQueue(HTTPAPI_VERSION Version, [Optional, MarshalAs(UnmanagedType.LPWStr)] string? Name,
[In, Optional] SECURITY_ATTRIBUTES? SecurityAttributes, [In, Optional] HTTP_CREATE_REQUEST_QUEUE_FLAG Flags,
out SafeHREQQUEUE RequestQueueHandle);
/// The HttpCreateServerSession function creates a server session for the specified version.
///
///
/// An HTTPAPI_VERSION structure that indicates the version of the server session. For version 2.0, declare an instance of the structure
/// and set it to the predefined value HTTPAPI_VERSION_2 before passing it to HttpCreateServerSession.
///
/// The version must be 2.0; HttpCreateServerSession does not support version 1.0 request queues.
///
/// A pointer to the variable that receives the ID of the server session.
/// Reserved. Must be zero.
///
/// If the function succeeds, it returns NO_ERROR.
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_REVISION_MISMATCH
/// The version passed is invalid or unsupported.
///
/// -
/// ERROR_INVALID_PARAMETER
/// The pServerSessionId parameter is null or the Reserved is non zero.
///
///
///
///
///
/// Server sessions own a set of URL Groups. They are top-level configuration containers for configuration information that applies to
/// all of the URL Groups created under them. For more information about configuring a server session, see HttpSetServerSessionProperty.
///
/// The HTTP Server API does not support asynchronous I/O for server sessions.
///
/// When the server session is no longer required, or before the application terminates, application must delete the server session by
/// calling HttpCloseServerSession. When a server session is deleted all of the associated URL Groups are also automatically deleted.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpcreateserversession HTTPAPI_LINKAGE ULONG HttpCreateServerSession(
// [in] HTTPAPI_VERSION Version, [out] PHTTP_SERVER_SESSION_ID ServerSessionId, [in] ULONG Reserved );
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpCreateServerSession")]
public static Win32Error HttpCreateServerSession(HTTPAPI_VERSION Version, out SafeHTTP_SERVER_SESSION_ID ServerSessionId, uint Reserved = 0)
{
var err = HttpCreateServerSession(Version, out HTTP_SERVER_SESSION_ID id, Reserved);
ServerSessionId = new(id);
return err;
}
/// The HttpCreateUrlGroup function creates a URL Group under the specified server session.
/// The identifier of the server session under which the URL Group is created.
/// A pointer to the variable that receives the ID of the URL Group.
/// Reserved. Must be zero.
///
/// If the function succeeds, it returns NO_ERROR
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
///
/// The ServerSessionId parameter indicates a non-existing Server Session. The pUrlGroupId parameter is null. The
/// Reserved parameter is non-zero.
///
///
///
///
///
///
/// URL Groups are configuration containers for a set of URLs. They are created under the server session and inherit the configuration
/// settings of the server session. When a configuration parameter is set on the URL Group, it overrides the configuration set on the
/// server session. For more information about the setting configurations for the URL Group, see HttpSetUrlGroupProperty.
///
///
/// After the URL group is created it must be associated with a request queue to receive requests. To associate the URL Group with a
/// request queue, the application calls HttpSetUrlGroupProperty with the HttpServerBindingProperty property. If this property is
/// not set, matching requests for the URL Group are not delivered to a request queue and the HTTP Server API generates a 503 response.
///
///
/// The URL Group association with a request queue is dynamic. The association with the servers session cannot be changed until either
/// the server session or the URL Group is deleted. When a server session is deleted all of the associated URL Groups are also
/// automatically closed.
///
/// The URL Group is initially created as an empty group. URLs must be added to the group by calling HttpAddUrlToUrlGroup.
/// Application may create multiple URL Groups for the following reasons:
///
/// -
/// To set distinct configurations for different portions of URL name space on which it is listening.
///
/// -
/// To set separate request queues for different portions of URL name space on which it is listening.
///
///
///
/// Applications should combine URLs into groups as much as possible; otherwise performance will degrade and increased memory consumption
/// of the system will affect the scalability.
///
/// The HTTP Server API does not support asynchronous I/O on URL Groups.
/// When the URL group is no longer needed or before the application terminates it must delete the URL Group by calling HttpCloseUrlGroup.
/// The URL Group is created with the same version as the server session under which it is created.
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpcreateurlgroup HTTPAPI_LINKAGE ULONG HttpCreateUrlGroup( [in]
// HTTP_SERVER_SESSION_ID ServerSessionId, [out] PHTTP_URL_GROUP_ID pUrlGroupId, [in] ULONG Reserved );
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpCreateUrlGroup")]
public static Win32Error HttpCreateUrlGroup(HTTP_SERVER_SESSION_ID ServerSessionId, out SafeHTTP_URL_GROUP_ID pUrlGroupId, uint Reserved = 0)
{
var err = HttpCreateUrlGroup(ServerSessionId, out HTTP_SERVER_SESSION_ID id, Reserved);
pUrlGroupId = new(id);
return err;
}
///
/// Declares a resource-to-subresource relationship to use for an HTTP server push. HTTP.sys then performs an HTTP 2.0 server push for
/// the given resource, if the underlying protocol, connection, client, and policies allow the push operation.
///
/// The handle to an HTTP.sys request queue that the HttpCreateRequestQueue function returned.
///
/// The opaque identifier of the request that is declaring the push operation. The request must be from the specified queue handle.
///
///
/// The HTTP verb to use for the push operation. The HTTP.sys push operation only supports HttpVerbGET and HttpVerbHEAD.
///
/// The path portion of the URL for the resource being pushed.
///
/// The query portion of the URL for the resource being pushed. This string should not include the leading question mark (?).
///
///
/// The request headers for the push operation.
///
/// You should not provide a Host header, because HTTP.sys automatically generates the correct Host information. HTTP.sys does not
/// support cross-origin push operations, so HTTP.sys enforces and generates Host information that matches the original client-initiated request.
///
///
/// The push request is not allowed to have an entity body, so you cannot include a non-zero Content-Length header or any
/// Transfer-Encoding header.
///
///
///
/// If the function succeeds, it returns NO_ERROR.
/// If the function fails, it returns a system error code defined in WinError.h.
///
///
/// You should call HttpDeclarePush before you send any response bytes that would cause the client to discover the subresource
/// itself. Failure to observe this order results in a race between the server that is pushing the resource and the client that is
/// retrieving the resources, which can waste bandwidth. The server application should only use HttpDeclarePush to push resources
/// that the server application is highly confident are needed and not already cached by the client. If the server application pushes
/// other resources, unnecessary use of bandwidth and CPU may occur.
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpdeclarepush HTTPAPI_LINKAGE ULONG HttpDeclarePush( [in] HANDLE
// RequestQueueHandle, [in] HTTP_REQUEST_ID RequestId, [in] HTTP_VERB Verb, [in] PCWSTR Path, [in, optional] PCSTR Query, [in, optional]
// PHTTP_REQUEST_HEADERS Headers );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpDeclarePush")]
public static extern Win32Error HttpDeclarePush([In] HREQQUEUE RequestQueueHandle, [In] HTTP_REQUEST_ID RequestId, [In] HTTP_VERB Verb,
[MarshalAs(UnmanagedType.LPWStr)] string Path, [Optional, MarshalAs(UnmanagedType.LPStr)] string? Query, [In, Optional] IntPtr Headers);
///
/// Declares a resource-to-subresource relationship to use for an HTTP server push. HTTP.sys then performs an HTTP 2.0 server push for
/// the given resource, if the underlying protocol, connection, client, and policies allow the push operation.
///
/// The handle to an HTTP.sys request queue that the HttpCreateRequestQueue function returned.
///
/// The opaque identifier of the request that is declaring the push operation. The request must be from the specified queue handle.
///
///
/// The HTTP verb to use for the push operation. The HTTP.sys push operation only supports HttpVerbGET and HttpVerbHEAD.
///
/// The path portion of the URL for the resource being pushed.
///
/// The query portion of the URL for the resource being pushed. This string should not include the leading question mark (?).
///
///
/// The request headers for the push operation.
///
/// You should not provide a Host header, because HTTP.sys automatically generates the correct Host information. HTTP.sys does not
/// support cross-origin push operations, so HTTP.sys enforces and generates Host information that matches the original client-initiated request.
///
///
/// The push request is not allowed to have an entity body, so you cannot include a non-zero Content-Length header or any
/// Transfer-Encoding header.
///
///
///
/// If the function succeeds, it returns NO_ERROR.
/// If the function fails, it returns a system error code defined in WinError.h.
///
///
/// You should call HttpDeclarePush before you send any response bytes that would cause the client to discover the subresource
/// itself. Failure to observe this order results in a race between the server that is pushing the resource and the client that is
/// retrieving the resources, which can waste bandwidth. The server application should only use HttpDeclarePush to push resources
/// that the server application is highly confident are needed and not already cached by the client. If the server application pushes
/// other resources, unnecessary use of bandwidth and CPU may occur.
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpdeclarepush HTTPAPI_LINKAGE ULONG HttpDeclarePush( [in] HANDLE
// RequestQueueHandle, [in] HTTP_REQUEST_ID RequestId, [in] HTTP_VERB Verb, [in] PCWSTR Path, [in, optional] PCSTR Query, [in, optional]
// PHTTP_REQUEST_HEADERS Headers );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpDeclarePush")]
public static extern Win32Error HttpDeclarePush([In] HREQQUEUE RequestQueueHandle, [In] HTTP_REQUEST_ID RequestId, [In] HTTP_VERB Verb,
[MarshalAs(UnmanagedType.LPWStr)] string Path, [Optional, MarshalAs(UnmanagedType.LPStr)] string? Query, in HTTP_REQUEST_HEADERS Headers);
/// Delegates a request from the source request queue to the target request queue.
///
/// Type: _In_ HANDLE
/// A handle to the source request queue.
///
///
/// Type: _In_ HANDLE
/// A handle to the target request queue.
///
///
/// Type: _In_ HTTP_REQUEST_ID
/// A unique request ID received with HttpReceiveHttpRequest.
///
///
/// Type: _In_ HTTP_URL_GROUP_ID
/// The url group id of the target url group.
///
///
/// Type: _In_ ULONG
/// The number of entries in the PropertyInfoSet array.
///
///
/// Type: _In_ **PHTTP_DELEGATE_REQUEST_PROPERTY_INFO**
/// An array of properties to be set on request when delegating.
///
/// A ULONG containing an NTSTATUS completion status.
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpdelegaterequestex HTTPAPI_LINKAGE ULONG HttpDelegateRequestEx(
// HANDLE RequestQueueHandle, HANDLE DelegateQueueHandle, HTTP_REQUEST_ID RequestId, HTTP_URL_GROUP_ID DelegateUrlGroupId, ULONG
// PropertyInfoSetSize, PHTTP_DELEGATE_REQUEST_PROPERTY_INFO PropertyInfoSet );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpDelegateRequestEx")]
public static extern Win32Error HttpDelegateRequestEx(HREQQUEUE RequestQueueHandle, HREQQUEUE DelegateQueueHandle, HTTP_REQUEST_ID RequestId,
HTTP_URL_GROUP_ID DelegateUrlGroupId, uint PropertyInfoSetSize, in HTTP_DELEGATE_REQUEST_PROPERTY_INFO PropertyInfoSet);
///
/// The HttpDeleteServiceConfiguration function deletes specified data, such as IP addresses or SSL Certificates, from the HTTP
/// Server API configuration store, one record at a time.
///
/// This parameter is reserved and must be zero.
///
/// Type of configuration. This parameter is one of the values in the HTTP_SERVICE_CONFIG_ID enumeration.
///
///
/// ConfigId value
/// Meaning
///
/// -
/// HttpServiceConfigIPListenList
/// Deletes a specified IP address from the IP Listen List.
///
/// -
/// HttpServiceConfigSSLCertInfo
/// Deletes a specified SSL certificate record.
///
/// -
/// HttpServiceConfigUrlAclInfo
/// Deletes a specified URL reservation record.
///
/// -
/// HttpServiceConfigTimeout
/// Deletes a specified connection timeout. Windows Vista and later: This enumeration is supported.
///
/// -
/// HttpServiceConfigSslSniCertInfo
///
/// Deletes a specified SSL Server Name Indication (SNI) certificate record. Windows 8 and later: This enumeration value is supported.
///
///
/// -
/// HttpServiceConfigSslCcsCertInfo
///
/// Deletes the SSL certificate record that specifies that Http.sys should consult the Centralized Certificate Store (CCS) store to find
/// certificates if the port receives a Transport Layer Security (TLS) handshake. The port is specified by the KeyDesc member of
/// the HTTP_SERVICE_CONFIG_SSL_CCS_SET structure that you pass to the pConfigInformation parameter. Windows 8 and later:
/// This enumeration value is supported.
///
///
///
///
///
/// Pointer to a buffer that contains data required for the type of configuration specified in the ConfigId parameter.
///
///
/// ConfigId value
/// Meaning
///
/// -
/// HttpServiceConfigIPListenList
/// HTTP_SERVICE_CONFIG_IP_LISTEN_PARAM structure.
///
/// -
/// HttpServiceConfigSSLCertInfo
/// HTTP_SERVICE_CONFIG_SSL_SET structure.
///
/// -
/// HttpServiceConfigUrlAclInfo
/// HTTP_SERVICE_CONFIG_URLACL_SET structure.
///
/// -
/// HttpServiceConfigTimeouts
/// HTTP_SERVICE_CONFIG_TIMEOUT_KEY structure. Windows Vista and later: This structure is supported.
///
/// -
/// HttpServiceConfigSslSniCertInfo
///
/// HTTP_SERVICE_CONFIG_SSL_SNI_SET structure. The hostname will be "*" when the SSL central certificate store is queried and wildcard
/// bindings are used, and a host name for regular SNI. Windows 8 and later: This structure is supported.
///
///
/// -
/// HttpServiceConfigSslCcsCertInfo
/// HTTP_SERVICE_CONFIG_SSL_CCS_SET structure. Windows 8 and later: This structure is supported.
///
///
///
/// Size, in bytes, of the pConfigInformation buffer.
/// Reserved for future asynchronous operation. This parameter must be set to NULL.
///
/// If the function succeeds, the function returns NO_ERROR.
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One of the parameters are invalid.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpdeleteserviceconfiguration HTTPAPI_LINKAGE ULONG
// HttpDeleteServiceConfiguration( [in] HANDLE ServiceHandle, [in] HTTP_SERVICE_CONFIG_ID ConfigId, [in] PVOID pConfigInformation, [in]
// ULONG ConfigInformationLength, [in] LPOVERLAPPED pOverlapped );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpDeleteServiceConfiguration")]
public static extern Win32Error HttpDeleteServiceConfiguration([In, Optional] IntPtr ServiceHandle, [In] HTTP_SERVICE_CONFIG_ID ConfigId,
[In] IntPtr pConfigInformation, [In] uint ConfigInformationLength, [In, Optional] IntPtr pOverlapped);
///
/// The HttpDeleteServiceConfiguration function deletes specified data, such as IP addresses or SSL Certificates, from the HTTP
/// Server API configuration store, one record at a time.
///
/// The type of .
///
/// Contains data required for the type of configuration specified in the ConfigId parameter.
///
///
/// ConfigId value
/// Meaning
///
/// -
/// HttpServiceConfigIPListenList
/// HTTP_SERVICE_CONFIG_IP_LISTEN_PARAM structure.
///
/// -
/// HttpServiceConfigSSLCertInfo
/// HTTP_SERVICE_CONFIG_SSL_SET structure.
///
/// -
/// HttpServiceConfigUrlAclInfo
/// HTTP_SERVICE_CONFIG_URLACL_SET structure.
///
/// -
/// HttpServiceConfigTimeouts
/// HTTP_SERVICE_CONFIG_TIMEOUT_KEY structure. Windows Vista and later: This structure is supported.
///
/// -
/// HttpServiceConfigSslSniCertInfo
///
/// HTTP_SERVICE_CONFIG_SSL_SNI_SET structure. The hostname will be "*" when the SSL central certificate store is queried and wildcard
/// bindings are used, and a host name for regular SNI. Windows 8 and later: This structure is supported.
///
///
/// -
/// HttpServiceConfigSslCcsCertInfo
/// HTTP_SERVICE_CONFIG_SSL_CCS_SET structure. Windows 8 and later: This structure is supported.
///
///
///
///
/// If the function succeeds, the function returns NO_ERROR.
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One of the parameters are invalid.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
/// pConfigInformation
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpDeleteServiceConfiguration")]
public static Win32Error HttpDeleteServiceConfiguration(in T pConfigInformation) where T: struct
{
if (!CorrespondingTypeAttribute.CanSet(out var ConfigId))
throw new ArgumentOutOfRangeException(nameof(pConfigInformation));
using SafeCoTaskMemStruct mem = pConfigInformation;
return HttpDeleteServiceConfiguration(default, ConfigId, mem, mem.Size, default);
}
/// Retrieves a URL group ID for a URL and a request queue.
///
/// Type: _In_ PCWSTR
/// The URL whose URL group to query.
///
///
/// Type: _In_ HANDLE
/// The request queue associated with the URL group.
///
///
/// Type: _Out_ PHTTP_URL_GROUP_ID
/// The matching URL group ID.
///
/// A ULONG containing an NTSTATUS completion status.
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpfindurlgroupid HTTPAPI_LINKAGE ULONG HttpFindUrlGroupId( PCWSTR
// FullyQualifiedUrl, HANDLE RequestQueueHandle, PHTTP_URL_GROUP_ID UrlGroupId );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpFindUrlGroupId")]
public static extern Win32Error HttpFindUrlGroupId([MarshalAs(UnmanagedType.LPWStr)] string FullyQualifiedUrl, HREQQUEUE RequestQueueHandle,
in HTTP_URL_GROUP_ID UrlGroupId);
///
/// The HttpFlushResponseCache function removes from the HTTP Server API cache associated with a given request queue all response
/// fragments that have a name whose site portion matches a specified UrlPrefix. The application must previously have called HttpAddUrl,
/// or HttpAddUrlToUrlGroup to add this UrlPrefix or a valid prefix of it to the request queue in question, and then called
/// HttpAddFragmentToCache to cache the associated response fragment or fragments.
///
///
///
/// Handle to the request queue with which this cache is associated. A request queue is created and its handle returned by a call to the
/// HttpCreateRequestQueue function.
///
///
/// Windows Server 2003 with SP1 and Windows XP with SP2: The handle to the request queue is created by the HttpCreateHttpHandle function.
///
///
///
/// Pointer to a UrlPrefix string to match against the site portion of fragment names. The application must previously have called
/// HttpAddUrl to add this UrlPrefix or a valid prefix of it to the request queue in question, and then called HttpAddFragmentToCache to
/// cache the associated response fragment.
///
///
/// This parameter can contain the following flag:
/// HTTP_FLUSH_RESPONSE_FLAG_RECURSIVE
///
/// Causes response fragments that have names in which the site portion is a hierarchical descendant of the specified UrlPrefix to be
/// removed from the fragment cache, in addition to those fragments having site portions that directly match.
///
///
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure, or for synchronous calls, set it to NULL.
///
/// A synchronous call blocks until the cache operation is complete, whereas an asynchronous call immediately returns ERROR_IO_PENDING
/// and the calling application then uses GetOverlappedResult or I/O completion ports to determine when the operation is completed. For
/// more information about using OVERLAPPED structures for synchronization, see Synchronization and Overlapped Input and Output.
///
///
///
/// If the function succeeds, the return value is NO_ERROR.
///
/// If the function is used asynchronously, a return value of ERROR_IO_PENDING indicates that the cache request is queued and completes
/// later through normal overlapped I/O completion mechanisms.
///
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One of the parameters are invalid.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpflushresponsecache HTTPAPI_LINKAGE ULONG HttpFlushResponseCache(
// [in] HANDLE RequestQueueHandle, [in] PCWSTR UrlPrefix, [in] ULONG Flags, [in] LPOVERLAPPED Overlapped );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpFlushResponseCache")]
public static extern Win32Error HttpFlushResponseCache([In] HREQQUEUE RequestQueueHandle, [MarshalAs(UnmanagedType.LPWStr)] string UrlPrefix,
[In] HTTP_FLUSH_RESPONSE_FLAG Flags, in NativeOverlapped Overlapped);
///
/// The HttpFlushResponseCache function removes from the HTTP Server API cache associated with a given request queue all response
/// fragments that have a name whose site portion matches a specified UrlPrefix. The application must previously have called HttpAddUrl,
/// or HttpAddUrlToUrlGroup to add this UrlPrefix or a valid prefix of it to the request queue in question, and then called
/// HttpAddFragmentToCache to cache the associated response fragment or fragments.
///
///
///
/// Handle to the request queue with which this cache is associated. A request queue is created and its handle returned by a call to the
/// HttpCreateRequestQueue function.
///
///
/// Windows Server 2003 with SP1 and Windows XP with SP2: The handle to the request queue is created by the HttpCreateHttpHandle function.
///
///
///
/// Pointer to a UrlPrefix string to match against the site portion of fragment names. The application must previously have called
/// HttpAddUrl to add this UrlPrefix or a valid prefix of it to the request queue in question, and then called HttpAddFragmentToCache to
/// cache the associated response fragment.
///
///
/// This parameter can contain the following flag:
/// HTTP_FLUSH_RESPONSE_FLAG_RECURSIVE
///
/// Causes response fragments that have names in which the site portion is a hierarchical descendant of the specified UrlPrefix to be
/// removed from the fragment cache, in addition to those fragments having site portions that directly match.
///
///
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure, or for synchronous calls, set it to NULL.
///
/// A synchronous call blocks until the cache operation is complete, whereas an asynchronous call immediately returns ERROR_IO_PENDING
/// and the calling application then uses GetOverlappedResult or I/O completion ports to determine when the operation is completed. For
/// more information about using OVERLAPPED structures for synchronization, see Synchronization and Overlapped Input and Output.
///
///
///
/// If the function succeeds, the return value is NO_ERROR.
///
/// If the function is used asynchronously, a return value of ERROR_IO_PENDING indicates that the cache request is queued and completes
/// later through normal overlapped I/O completion mechanisms.
///
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One of the parameters are invalid.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpflushresponsecache HTTPAPI_LINKAGE ULONG HttpFlushResponseCache(
// [in] HANDLE RequestQueueHandle, [in] PCWSTR UrlPrefix, [in] ULONG Flags, [in] LPOVERLAPPED Overlapped );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpFlushResponseCache")]
public static extern Win32Error HttpFlushResponseCache([In] HREQQUEUEv1 RequestQueueHandle, [MarshalAs(UnmanagedType.LPWStr)] string UrlPrefix,
[In] HTTP_FLUSH_RESPONSE_FLAG Flags, [In, Optional] IntPtr Overlapped);
///
/// The HttpInitialize function initializes the HTTP Server API driver, starts it, if it has not already been started, and
/// allocates data structures for the calling application to support response-queue creation and other operations. Call this function
/// before calling any other functions in the HTTP Server API.
///
///
/// HTTP version. This parameter is an HTTPAPI_VERSION structure. For the current version, declare an instance of the structure and set
/// it to the pre-defined value HTTPAPI_VERSION_1 before passing it to HttpInitialize.
///
///
/// Initialization options, which can include one or both of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// HTTP_INITIALIZE_CONFIG
///
/// Perform initialization for applications that use the HTTP configuration functions, HttpSetServiceConfiguration,
/// HttpQueryServiceConfiguration, HttpDeleteServiceConfiguration, and HttpIsFeatureSupported.
///
///
/// -
/// HTTP_INITIALIZE_SERVER
/// Perform initialization for applications that use the HTTP Server API.
///
///
///
/// This parameter is reserved, and must be NULL.
///
/// If the function succeeds, then the return value is NO_ERROR.
/// If the function fails, then the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// The Flags parameter contains an unsupported value.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
///
/// Call HttpTerminate when the application completes. All the same flags that were passed to HttpInitialize in the Flags
/// parameter must also be passed to HttpTerminate. An application can call HttpInitialize repeatedly, provided that each
/// call to HttpInitialize is later matched by a corresponding call to HttpTerminate.
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpinitialize HTTPAPI_LINKAGE ULONG HttpInitialize( [in]
// HTTPAPI_VERSION Version, [in] ULONG Flags, [in, out] PVOID pReserved );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpInitialize")]
public static extern Win32Error HttpInitialize(HTTPAPI_VERSION Version, HTTP_INIT Flags, IntPtr pReserved = default);
/// Checks whether a particular feature is supported.
///
/// Type: _In_ HTTP_FEATURE_ID
/// The identifier of the feature.
///
///
/// TRUE
/// if the feature is supported, otherwise
/// FALSE
/// .
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpisfeaturesupported BOOL HttpIsFeatureSupported( HTTP_FEATURE_ID
// FeatureId );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpIsFeatureSupported")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool HttpIsFeatureSupported(HTTP_FEATURE_ID FeatureId);
///
/// The HttpPrepareUrl function parses, analyzes, and normalizes a non-normalized Unicode or punycode URL so it is safe and valid
/// to use in other HTTP functions.
///
/// A pointer to a string that represents the non-normalized Unicode or punycode URL to prepare.
///
/// On successful output, a pointer to a string that represents the normalized URL.
/// Note Free PreparedUrl using HeapFree.
///
///
/// If the function succeeds, it returns ERROR_SUCCESS.
/// If the function fails, it returns one of the following or a system error code defined in WinError.h.
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpprepareurl HTTPAPI_LINKAGE ULONG HttpPrepareUrl( PVOID Reserved,
// ULONG Flags, [in] PCWSTR Url, [out] PWSTR *PreparedUrl );
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpPrepareUrl")]
public static Win32Error HttpPrepareUrl(string Url, out string? PreparedUrl)
{
var err = HttpPrepareUrl(default, default, Url, out var pUrl);
PreparedUrl = err.Succeeded ? pUrl.ToString(-1, CharSet.Unicode) : null;
return err;
}
///
/// The HttpQueryRequestQueueProperty function queries a property of the request queue identified by the specified handle.
///
///
///
/// A member of the HTTP_SERVER_PROPERTY enumeration that describes the property type that is set. This can be one of the following:
///
///
/// Property
/// Meaning
///
/// -
/// HttpServer503VerbosityProperty
/// Queries the current verbosity level of 503 responses generated for the requests queue.
///
/// -
/// HttpServerQueueLengthProperty
/// Queries the limit on the number of outstanding requests in the request queue.
///
/// -
/// HttpServerStateProperty
/// Queries the current state of the request queue. The state must be either active or inactive.
///
///
///
///
/// A pointer to the buffer that receives the property information.
/// pPropertyInformation
/// points to one of the following property information values based on the property that is set.
///
///
/// Property
/// Value
///
/// -
/// HttpServerStateProperty
/// HTTP_ENABLED_STATE (enumeration member)
///
/// -
/// HttpServerQueueLengthProperty
/// ULONG
///
/// -
/// HttpServer503VerbosityProperty
/// HTTP_503_RESPONSE_VERBOSITY (enumeration member)
///
///
///
/// The length, in bytes, of the buffer pointed to by the pPropertyInformation parameter.
/// Reserved. Must be zero.
///
/// The number, in bytes, returned in the pPropertyInformation buffer if not NULL.
///
/// If the output buffer is too small, the call fails with a return value of ERROR_MORE_DATA. The value pointed to by
/// pReturnLength can be used to determine the minimum length of the buffer required for the call to succeed.
///
///
/// This parameter is reserved and must be NULL.
///
/// If the function succeeds, it returns NO_ERROR.
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
///
/// The Reserved parameter is not zero or the pReserved parameter is not NULL. The property type specified in the
/// Property parameter is not supported on request queues. The pPropertyInformation parameter is NULL. The
/// PropertyInformationLength parameter is zero. The application does not have permission to open the request queue.
///
///
/// -
/// ERROR_MORE_DATA
///
/// The size, in bytes, of the buffer pointed to by the pPropertyInformation parameter is too small to receive the property
/// information. Call the function again with a buffer at least as large as the size pointed to by pReturnLength on exit.
///
///
/// -
/// ERROR_NOT_SUPPORTED
///
/// The handle to the request queue is an HTTP version 1.0 handle. Property management is only supported for HTTP version 2.0 and later
/// request queues.
///
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpqueryrequestqueueproperty HTTPAPI_LINKAGE ULONG
// HttpQueryRequestQueueProperty( HANDLE RequestQueueHandle, [in] HTTP_SERVER_PROPERTY Property, [out] PVOID PropertyInformation, [in]
// ULONG PropertyInformationLength, [in] ULONG Reserved1, [out, optional] PULONG ReturnLength, [in] PVOID Reserved2 );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpQueryRequestQueueProperty")]
public static extern Win32Error HttpQueryRequestQueueProperty(HREQQUEUE RequestQueueHandle, [In] HTTP_SERVER_PROPERTY Property,
[Out] IntPtr PropertyInformation, [In] uint PropertyInformationLength, [In, Optional] uint Reserved1, out uint ReturnLength,
[In, Optional] IntPtr Reserved2);
/// The HttpQueryServerSessionProperty function queries a server property on the specified server session.
/// The server session for which the property setting is returned.
///
/// A member of the HTTP_SERVER_PROPERTY enumeration that describes the property type that is queried. This can be one of the following.
///
///
/// Property
/// Meaning
///
/// -
/// HttpServerStateProperty
/// Queries the current state of the server session.
///
/// -
/// HttpServerTimeoutsProperty
/// Queries the server session connection timeout limits.
///
/// -
/// HttpServerQosProperty
/// Queries the bandwidth throttling for the server session. By default, the HTTP Server API does not limit bandwidth.
///
/// -
/// HttpServerAuthenticationProperty
/// Queries kernel mode server-side authentication for the Basic, NTLM, Negotiate, and Digest authentication schemes.
///
/// -
/// HttpServerChannelBindProperty
/// Queries the channel binding token (CBT) properties.
///
///
///
///
/// A pointer to the buffer that receives the property data.
/// pPropertyInformation
/// points to one of the following property data structures based on the property that is set.
///
///
/// Property
/// Structure
///
/// -
/// HttpServerStateProperty
/// HTTP_STATE_INFO
///
/// -
/// HttpServerQosProperty
/// HTTP_QOS_SETTING_INFO
///
/// -
/// HttpServerTimeoutsProperty
/// HTTP_TIMEOUT_LIMIT_INFO
///
/// -
/// HttpServerAuthenticationProperty
/// HTTP_SERVER_AUTHENTICATION_INFO
///
/// -
/// HttpServerChannelBindProperty
/// HTTP_CHANNEL_BIND_INFO
///
///
///
/// The length, in bytes, of the buffer pointed to by the pPropertyInformation parameter.
///
/// The number, in bytes, returned in the pPropertyInformation buffer.
///
/// If the output buffer is too small, the call fails with a return value of ERROR_MORE_DATA. The value pointed to by
/// pReturnLength can be used to determine the minimum length of the buffer required for the call to succeed.
///
///
///
/// If the function succeeds, it returns NO_ERROR
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
///
/// The property type specified in the Property parameter is not supported for server sessions. The ServerSessionId
/// parameter does not contain a valid server session. The pPropertyInformation parameter is NULL. The
/// PropertyInformationLength parameter is zero. The application does not have permission to query the server session properties.
/// Only the application that created the server session can query the properties.
///
///
/// -
/// ERROR_MORE_DATA
///
/// The size, in bytes, of the buffer pointed to by the pPropertyInformation parameter is too small to receive the property data.
/// On exit call the function again with a buffer at least as large as the size pointed to by pReturnLength on exit.
///
///
///
///
///
/// Querying the HttpServerLoggingProperty is not supported.
///
/// The pPropertyInformation parameter points to the configuration structure for the property type that is queried. The
/// PropertyInformationLength parameter specifies the size, in bytes, of the configuration structure. For example, when querying
/// the HttpServerTimeoutsProperty the pPropertyInformation parameter must point to a buffer that is at least the size of
/// the HTTP_TIMEOUT_LIMIT_INFO structure.
///
///
/// To specify the HttpServerQosProperty property in the pPropertyInformation parameter, set QosType to
/// HttpQosSettingTypeBandwidth inside the HTTP_QOS_SETTING_INFO structure, and pass a pointer to this structure in the parameter.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpqueryserversessionproperty HTTPAPI_LINKAGE ULONG
// HttpQueryServerSessionProperty( [in] HTTP_SERVER_SESSION_ID ServerSessionId, [in] HTTP_SERVER_PROPERTY Property, [out] PVOID
// PropertyInformation, [in] ULONG PropertyInformationLength, [out, optional] PULONG ReturnLength );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpQueryServerSessionProperty")]
public static extern Win32Error HttpQueryServerSessionProperty([In] HTTP_SERVER_SESSION_ID ServerSessionId, [In] HTTP_SERVER_PROPERTY Property,
[Out] IntPtr PropertyInformation, [In] uint PropertyInformationLength, out uint ReturnLength);
/// The HttpQueryServiceConfiguration function retrieves one or more HTTP Server API configuration records.
/// The type of .
/// The type of .
///
/// The configuration record query type. This parameter is one of the following values from the HTTP_SERVICE_CONFIG_ID enumeration.
///
///
/// ConfigId value
/// Meaning
///
/// -
/// HttpServiceConfigIPListenList
/// Queries the IP Listen List.
///
/// -
/// HttpServiceConfigSSLCertInfo
/// Queries the SSL store for a specific certificate record.
///
/// -
/// HttpServiceConfigUrlAclInfo
/// Queries URL reservation information.
///
/// -
/// HttpServiceConfigTimeout
/// Queries HTTP Server API wide connection timeouts. Windows Vista and later: This enumeration is supported.
///
/// -
/// HttpServiceConfigSslSniCertInfo
///
/// Queries the SSL Server Name Indication (SNI) store for a specific certificate record. Windows 8 and later: This enumeration
/// value is supported.
///
///
/// -
/// HttpServiceConfigSslCcsCertInfo
///
/// Queries the SSL configuration for an SSL Centralized Certificate Store (CCS) record on the port. The port is specified by the
/// KeyDesc member of the HTTP_SERVICE_CONFIG_SSL_CCS_QUERY structure that you pass to the pInputConfigInfo parameter.
/// Windows 8 and later: This enumeration value is supported.
///
///
///
///
///
/// A structure whose contents further define the query and of the type that correlates with ConfigId in the following table.
///
///
/// ConfigId value
/// Meaning
///
/// -
/// HttpServiceConfigIPListenList
/// No input data; set to NULL.
///
/// -
/// HttpServiceConfigSSLCertInfo
/// HTTP_SERVICE_CONFIG_SSL_QUERY structure.
///
/// -
/// HttpServiceConfigUrlAclInfo
/// HTTP_SERVICE_CONFIG_URLACL_QUERY structure.
///
/// -
/// HttpServiceConfigTimeout
/// HTTP_SERVICE_CONFIG_TIMEOUT_KEY structure. Windows Vista and later: This structure is supported.
///
/// -
/// HttpServiceConfigSslSniCertInfo
/// HTTP_SERVICE_CONFIG_SSL_SNI_QUERY structure. Windows 8 and later: This structure is supported.
///
/// -
/// HttpServiceConfigSslCcsCertInfo
/// HTTP_SERVICE_CONFIG_SSL_CCS_QUERY structure. Windows 8 and later: This structure is supported.
///
///
/// For more information, see the appropriate query structures.
///
///
/// A pointer to a buffer in which the query results are returned. The type of this buffer correlates with ConfigId.
///
///
/// ConfigId value
/// Meaning
///
/// -
/// HttpServiceConfigIPListenList
/// HTTP_SERVICE_CONFIG_IP_LISTEN_QUERY structure.
///
/// -
/// HttpServiceConfigSSLCertInfo
/// HTTP_SERVICE_CONFIG_SSL_SET structure.
///
/// -
/// HttpServiceConfigUrlAclInfo
/// HTTP_SERVICE_CONFIG_URLACL_SET structure.
///
/// -
/// HttpServiceConfigTimeout
/// HTTP_SERVICE_CONFIG_TIMEOUT_PARAM data type. Windows Vista and later: This structure is supported.
///
/// -
/// HttpServiceConfigSslSniCertInfo
/// HTTP_SERVICE_CONFIG_SSL_SNI_SET structure. Windows 8 and later: This structure is supported.
///
/// -
/// HttpServiceConfigSslCcsCertInfo
/// HTTP_SERVICE_CONFIG_SSL_CCS_SET structure. Windows 8 and later: This structure is supported.
///
///
///
///
/// If the function succeeds, the return value is NO_ERROR.
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One of the parameters are invalid.
///
/// -
/// ERROR_INSUFFICIENT_BUFFER
///
/// The buffer pointed to by pOutputConfigInfo is too small to receive the output data. Call the function again with a buffer at
/// least as large as the size pointed to by pReturnLength on exit.
///
///
/// -
/// ERROR_MORE_DATA
///
/// This error code is only returned when ConfigId is set to HttpServiceConfigTimeout. The buffer pointed to by
/// pOutputConfigInfo is too small to receive the output data. Call the function again with a buffer at least as large as the size
/// pointed to by pReturnLength on exit.
///
///
/// -
/// ERROR_NO_MORE_ITEMS
/// There are no more items to return that meet the specified criteria.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpQueryServiceConfiguration")]
public static Win32Error HttpQueryServiceConfiguration([In] HTTP_SERVICE_CONFIG_ID ConfigId,
in TIn pInput, out SafeCoTaskMemStruct pOutput) where TIn: struct where TOut: struct
{
using var mem = new SafeCoTaskMemStruct(pInput);
using var output = new SafeCoTaskMemStruct();
var err = HttpQueryServiceConfiguration(default, ConfigId, mem, mem.Size, output, output.Size, out var len, default);
if (err == Win32Error.ERROR_INSUFFICIENT_BUFFER)
{
output.Size = len;
err = HttpQueryServiceConfiguration(default, ConfigId, mem, mem.Size, output, output.Size, out _, default);
}
pOutput = err.Succeeded ? output.Value : default;
return err;
}
/// The HttpQueryServiceConfiguration function retrieves one or more HTTP Server API configuration records.
/// The type of .
///
/// The configuration record query type. This parameter is one of the following values from the HTTP_SERVICE_CONFIG_ID enumeration.
///
///
/// ConfigId value
/// Meaning
///
/// -
/// HttpServiceConfigIPListenList
/// Queries the IP Listen List.
///
/// -
/// HttpServiceConfigSSLCertInfo
/// Queries the SSL store for a specific certificate record.
///
/// -
/// HttpServiceConfigUrlAclInfo
/// Queries URL reservation information.
///
/// -
/// HttpServiceConfigTimeout
/// Queries HTTP Server API wide connection timeouts. Windows Vista and later: This enumeration is supported.
///
/// -
/// HttpServiceConfigSslSniCertInfo
///
/// Queries the SSL Server Name Indication (SNI) store for a specific certificate record. Windows 8 and later: This enumeration
/// value is supported.
///
///
/// -
/// HttpServiceConfigSslCcsCertInfo
///
/// Queries the SSL configuration for an SSL Centralized Certificate Store (CCS) record on the port. The port is specified by the
/// KeyDesc member of the HTTP_SERVICE_CONFIG_SSL_CCS_QUERY structure that you pass to the pInputConfigInfo parameter.
/// Windows 8 and later: This enumeration value is supported.
///
///
///
///
///
/// A pointer to a buffer in which the query results are returned. The type of this buffer correlates with ConfigId.
///
///
/// ConfigId value
/// Meaning
///
/// -
/// HttpServiceConfigIPListenList
/// HTTP_SERVICE_CONFIG_IP_LISTEN_QUERY structure.
///
/// -
/// HttpServiceConfigSSLCertInfo
/// HTTP_SERVICE_CONFIG_SSL_SET structure.
///
/// -
/// HttpServiceConfigUrlAclInfo
/// HTTP_SERVICE_CONFIG_URLACL_SET structure.
///
/// -
/// HttpServiceConfigTimeout
/// HTTP_SERVICE_CONFIG_TIMEOUT_PARAM data type. Windows Vista and later: This structure is supported.
///
/// -
/// HttpServiceConfigSslSniCertInfo
/// HTTP_SERVICE_CONFIG_SSL_SNI_SET structure. Windows 8 and later: This structure is supported.
///
/// -
/// HttpServiceConfigSslCcsCertInfo
/// HTTP_SERVICE_CONFIG_SSL_CCS_SET structure. Windows 8 and later: This structure is supported.
///
///
///
///
/// If the function succeeds, the return value is NO_ERROR.
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One of the parameters are invalid.
///
/// -
/// ERROR_INSUFFICIENT_BUFFER
///
/// The buffer pointed to by pOutputConfigInfo is too small to receive the output data. Call the function again with a buffer at
/// least as large as the size pointed to by pReturnLength on exit.
///
///
/// -
/// ERROR_MORE_DATA
///
/// This error code is only returned when ConfigId is set to HttpServiceConfigTimeout. The buffer pointed to by
/// pOutputConfigInfo is too small to receive the output data. Call the function again with a buffer at least as large as the size
/// pointed to by pReturnLength on exit.
///
///
/// -
/// ERROR_NO_MORE_ITEMS
/// There are no more items to return that meet the specified criteria.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpQueryServiceConfiguration")]
public static Win32Error HttpQueryServiceConfiguration([In] HTTP_SERVICE_CONFIG_ID ConfigId,
out SafeCoTaskMemStruct pOutput) where TOut : struct
{
using var output = new SafeCoTaskMemStruct();
var err = HttpQueryServiceConfiguration(default, ConfigId, default, 0, output, output.Size, out var len, default);
if (err == Win32Error.ERROR_INSUFFICIENT_BUFFER)
{
output.Size = len;
err = HttpQueryServiceConfiguration(default, ConfigId, default, 0, output, output.Size, out _, default);
}
pOutput = err.Succeeded ? output.Value : default;
return err;
}
/// The HttpQueryServiceConfiguration function retrieves one or more HTTP Server API configuration records.
/// Reserved. Must be zero.
///
/// The configuration record query type. This parameter is one of the following values from the HTTP_SERVICE_CONFIG_ID enumeration.
///
///
/// ConfigId value
/// Meaning
///
/// -
/// HttpServiceConfigIPListenList
/// Queries the IP Listen List.
///
/// -
/// HttpServiceConfigSSLCertInfo
/// Queries the SSL store for a specific certificate record.
///
/// -
/// HttpServiceConfigUrlAclInfo
/// Queries URL reservation information.
///
/// -
/// HttpServiceConfigTimeout
/// Queries HTTP Server API wide connection timeouts. Windows Vista and later: This enumeration is supported.
///
/// -
/// HttpServiceConfigSslSniCertInfo
///
/// Queries the SSL Server Name Indication (SNI) store for a specific certificate record. Windows 8 and later: This enumeration
/// value is supported.
///
///
/// -
/// HttpServiceConfigSslCcsCertInfo
///
/// Queries the SSL configuration for an SSL Centralized Certificate Store (CCS) record on the port. The port is specified by the
/// KeyDesc member of the HTTP_SERVICE_CONFIG_SSL_CCS_QUERY structure that you pass to the pInputConfigInfo parameter.
/// Windows 8 and later: This enumeration value is supported.
///
///
///
///
///
///
/// A pointer to a structure whose contents further define the query and of the type that correlates with ConfigId in the
/// following table.
///
///
///
/// ConfigId value
/// Meaning
///
/// -
/// HttpServiceConfigIPListenList
/// No input data; set to NULL.
///
/// -
/// HttpServiceConfigSSLCertInfo
/// HTTP_SERVICE_CONFIG_SSL_QUERY structure.
///
/// -
/// HttpServiceConfigUrlAclInfo
/// HTTP_SERVICE_CONFIG_URLACL_QUERY structure.
///
/// -
/// HttpServiceConfigTimeout
/// HTTP_SERVICE_CONFIG_TIMEOUT_KEY structure. Windows Vista and later: This structure is supported.
///
/// -
/// HttpServiceConfigSslSniCertInfo
/// HTTP_SERVICE_CONFIG_SSL_SNI_QUERY structure. Windows 8 and later: This structure is supported.
///
/// -
/// HttpServiceConfigSslCcsCertInfo
/// HTTP_SERVICE_CONFIG_SSL_CCS_QUERY structure. Windows 8 and later: This structure is supported.
///
///
/// For more information, see the appropriate query structures.
///
/// Size, in bytes, of the pInputConfigInfo buffer.
///
/// A pointer to a buffer in which the query results are returned. The type of this buffer correlates with ConfigId.
///
///
/// ConfigId value
/// Meaning
///
/// -
/// HttpServiceConfigIPListenList
/// HTTP_SERVICE_CONFIG_IP_LISTEN_QUERY structure.
///
/// -
/// HttpServiceConfigSSLCertInfo
/// HTTP_SERVICE_CONFIG_SSL_SET structure.
///
/// -
/// HttpServiceConfigUrlAclInfo
/// HTTP_SERVICE_CONFIG_URLACL_SET structure.
///
/// -
/// HttpServiceConfigTimeout
/// HTTP_SERVICE_CONFIG_TIMEOUT_PARAM data type. Windows Vista and later: This structure is supported.
///
/// -
/// HttpServiceConfigSslSniCertInfo
/// HTTP_SERVICE_CONFIG_SSL_SNI_SET structure. Windows 8 and later: This structure is supported.
///
/// -
/// HttpServiceConfigSslCcsCertInfo
/// HTTP_SERVICE_CONFIG_SSL_CCS_SET structure. Windows 8 and later: This structure is supported.
///
///
///
/// Size, in bytes, of the pOutputConfigInfo buffer.
///
/// A pointer to a variable that receives the number of bytes to be written in the output buffer. If the output buffer is too small, the
/// call fails with a return value of ERROR_INSUFFICIENT_BUFFER. The value pointed to by pReturnLength can be used to
/// determine the minimum length the buffer requires for the call to succeed.
///
/// Reserved for asynchronous operation and must be set to NULL.
///
/// If the function succeeds, the return value is NO_ERROR.
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One of the parameters are invalid.
///
/// -
/// ERROR_INSUFFICIENT_BUFFER
///
/// The buffer pointed to by pOutputConfigInfo is too small to receive the output data. Call the function again with a buffer at
/// least as large as the size pointed to by pReturnLength on exit.
///
///
/// -
/// ERROR_MORE_DATA
///
/// This error code is only returned when ConfigId is set to HttpServiceConfigTimeout. The buffer pointed to by
/// pOutputConfigInfo is too small to receive the output data. Call the function again with a buffer at least as large as the size
/// pointed to by pReturnLength on exit.
///
///
/// -
/// ERROR_NO_MORE_ITEMS
/// There are no more items to return that meet the specified criteria.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpqueryserviceconfiguration HTTPAPI_LINKAGE ULONG
// HttpQueryServiceConfiguration( [in] HANDLE ServiceHandle, [in] HTTP_SERVICE_CONFIG_ID ConfigId, [in, optional] PVOID pInput, [in,
// optional] ULONG InputLength, [in, out, optional] PVOID pOutput, [in, optional] ULONG OutputLength, [out, optional] PULONG
// pReturnLength, [in] LPOVERLAPPED pOverlapped );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpQueryServiceConfiguration")]
public static extern Win32Error HttpQueryServiceConfiguration([In, Optional] IntPtr ServiceHandle, [In] HTTP_SERVICE_CONFIG_ID ConfigId,
[In, Optional] IntPtr pInput, [In, Optional] uint InputLength, [In, Out, Optional] IntPtr pOutput, [In, Optional] uint OutputLength,
out uint pReturnLength, [In, Optional] IntPtr pOverlapped);
/// The HttpQueryUrlGroupProperty function queries a property on the specified URL Group.
/// The ID of the URL Group for which the property setting is returned.
///
/// A member of the HTTP_SERVER_PROPERTY enumeration that describes the property type that is queried. This can be one of the following:
///
///
/// Property
/// Meaning
///
/// -
/// HttpServerAuthenticationProperty
/// Queries the enabled server-side authentication schemes.
///
/// -
/// HttpServerTimeoutsProperty
/// Queries the URL Group connection timeout limits.
///
/// -
/// HttpServerStateProperty
/// Queries the current state of the URL Group. The state can be either enabled or disabled.
///
/// -
/// HttpServerQosProperty
///
/// This value maps to the generic HTTP_QOS_SETTING_INFO structure with QosType set to either HttpQosSettingTypeBandwidth
/// or HttpQosSettingTypeConnectionLimit. If HttpQosSettingTypeBandwidth, queries the bandwidth throttling for the URL
/// Group. If HttpQosSettingTypeConnectionLimit, queries the maximum number of outstanding connections served for a URL group at
/// any time.
///
///
/// -
/// HttpServerChannelBindProperty
/// Queries the channel binding token (CBT) properties.
///
///
///
///
/// A pointer to the buffer that receives the property information.
/// pPropertyInformation
/// points to one of the following property information structures based on the property that is queried.
///
///
/// Property
/// Structure
///
/// -
/// HttpServerStateProperty
/// HTTP_STATE_INFO
///
/// -
/// HttpServerAuthenticationProperty
/// HTTP_SERVER_AUTHENTICATION_INFO
///
/// -
/// HttpServerQosProperty
/// HTTP_QOS_SETTING_INFO
///
/// -
/// HttpServerTimeoutsProperty
/// HTTP_TIMEOUT_LIMIT_INFO
///
/// -
/// HttpServerChannelBindProperty
/// HTTP_CHANNEL_BIND_INFO
///
///
///
/// The length, in bytes, of the buffer pointed to by the pPropertyInformation parameter.
///
/// The size, in bytes, returned in the pPropertyInformation buffer.
///
/// If the output buffer is too small, the call fails with a return value of ERROR_MORE_DATA. The value pointed to by
/// pReturnLength can be used to determine the minimum length of the buffer required for the call to succeed.
///
///
///
/// If the function succeeds, it returns NO_ERROR.
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
///
/// The property type specified in the Property parameter is not supported for URL Groups. The UrlGroupId parameter does
/// not identify a valid server URL Group. The pPropertyInformation parameter is NULL. The PropertyInformationLength
/// parameter is zero. The application does not have permission to query the URL Group properties. Only the application that created the
/// URL Group can query the properties.
///
///
/// -
/// ERROR_MORE_DATA
///
/// The size, in bytes, of the buffer pointed to by the pPropertyInformation parameter is too small to receive the property
/// information. Call the function again with a buffer at least as large as the size pointed to by pReturnLength on exit.
///
///
///
///
/// Querying the HttpServerLoggingProperty is not supported.
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpqueryurlgroupproperty HTTPAPI_LINKAGE ULONG
// HttpQueryUrlGroupProperty( [in] HTTP_URL_GROUP_ID UrlGroupId, [in] HTTP_SERVER_PROPERTY Property, [out] PVOID PropertyInformation,
// [in] ULONG PropertyInformationLength, [out, optional] PULONG ReturnLength );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpQueryUrlGroupProperty")]
public static extern Win32Error HttpQueryUrlGroupProperty([In] HTTP_URL_GROUP_ID UrlGroupId, [In] HTTP_SERVER_PROPERTY Property,
[Out] IntPtr PropertyInformation, [In] uint PropertyInformationLength, out uint ReturnLength);
///
/// The HttpReadFragmentFromCache function retrieves a response fragment having a specified name from the HTTP Server API cache.
///
///
///
/// Handle to the request queue with which the specified response fragment is associated. A request queue is created and its handle
/// returned by a call to the HttpCreateRequestQueue function.
///
///
/// Windows Server 2003 with SP1 and Windows XP with SP2: The handle to the request queue is created by the HttpCreateHttpHandle function.
///
///
///
/// Pointer to a UrlPrefix string that contains the name of the fragment to be retrieved. This must match a UrlPrefix string used in a
/// previous successful call to HttpAddFragmentToCache.
///
///
/// Optional pointer to an HTTP_BYTE_RANGE structure that indicates a starting offset in the specified fragment and byte-count to be
/// returned. NULL if not used, in which case the entire fragment is returned.
///
/// Pointer to a buffer into which the function copies the requested fragment.
/// Size, in bytes, of the pBuffer buffer.
///
///
/// Optional pointer to a variable that receives the number of bytes to be written into the output buffer. If BufferLength is less
/// than this number, the call fails with a return of ERROR_INSUFFICIENT_BUFFER, and the value pointed to by pBytesRead can be
/// used to determine the minimum length of buffer required for the call to succeed.
///
///
/// When making an asynchronous call using pOverlapped, set pBytesRead to NULL. Otherwise, when pOverlapped
/// is set to NULL, pBytesRead must contain a valid memory address, and not be set to NULL.
///
///
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure, or for synchronous calls, set it to NULL.
///
/// A synchronous call blocks until the cache operation is complete, whereas an asynchronous call immediately returns ERROR_IO_PENDING
/// and the calling application then uses GetOverlappedResult or I/O completion ports to determine when the operation is completed. For
/// more information about using OVERLAPPED structures for synchronization, see Synchronization and Overlapped Input and Output.
///
///
///
/// If the function succeeds, the return value is NO_ERROR.
///
/// If the function is used asynchronously, a return value of ERROR_IO_PENDING indicates that the cache request is queued and completes
/// later through normal overlapped I/O completion mechanisms.
///
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters is in an unusable form.
///
/// -
/// ERROR_MORE_DATA
///
/// The buffer pointed to by pBuffer is too small to receive all the requested data; the size of buffer required is pointed to by
/// pBytesRead unless it was NULL or the call was asynchronous. In the case of an asynchronous call, the value pointed to
/// by the lpNumberOfBytesTransferred parameter of the GetOverLappedResult function is set to the buffer size required.
///
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpreadfragmentfromcache HTTPAPI_LINKAGE ULONG
// HttpReadFragmentFromCache( [in] HANDLE RequestQueueHandle, [in] PCWSTR UrlPrefix, [in] PHTTP_BYTE_RANGE ByteRange, [out] PVOID Buffer,
// [in] ULONG BufferLength, [out] PULONG BytesRead, [in] LPOVERLAPPED Overlapped );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpReadFragmentFromCache")]
public static extern Win32Error HttpReadFragmentFromCache([In] HREQQUEUEv1 RequestQueueHandle, [MarshalAs(UnmanagedType.LPWStr)] string UrlPrefix,
in HTTP_BYTE_RANGE ByteRange, [Out] IntPtr Buffer, [In] uint BufferLength, out uint BytesRead, in NativeOverlapped Overlapped);
///
/// The HttpReadFragmentFromCache function retrieves a response fragment having a specified name from the HTTP Server API cache.
///
///
///
/// Handle to the request queue with which the specified response fragment is associated. A request queue is created and its handle
/// returned by a call to the HttpCreateRequestQueue function.
///
///
/// Windows Server 2003 with SP1 and Windows XP with SP2: The handle to the request queue is created by the HttpCreateHttpHandle function.
///
///
///
/// Pointer to a UrlPrefix string that contains the name of the fragment to be retrieved. This must match a UrlPrefix string used in a
/// previous successful call to HttpAddFragmentToCache.
///
///
/// Optional pointer to an HTTP_BYTE_RANGE structure that indicates a starting offset in the specified fragment and byte-count to be
/// returned. NULL if not used, in which case the entire fragment is returned.
///
/// Pointer to a buffer into which the function copies the requested fragment.
/// Size, in bytes, of the pBuffer buffer.
///
///
/// Optional pointer to a variable that receives the number of bytes to be written into the output buffer. If BufferLength is less
/// than this number, the call fails with a return of ERROR_INSUFFICIENT_BUFFER, and the value pointed to by pBytesRead can be
/// used to determine the minimum length of buffer required for the call to succeed.
///
///
/// When making an asynchronous call using pOverlapped, set pBytesRead to NULL. Otherwise, when pOverlapped
/// is set to NULL, pBytesRead must contain a valid memory address, and not be set to NULL.
///
///
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure, or for synchronous calls, set it to NULL.
///
/// A synchronous call blocks until the cache operation is complete, whereas an asynchronous call immediately returns ERROR_IO_PENDING
/// and the calling application then uses GetOverlappedResult or I/O completion ports to determine when the operation is completed. For
/// more information about using OVERLAPPED structures for synchronization, see Synchronization and Overlapped Input and Output.
///
///
///
/// If the function succeeds, the return value is NO_ERROR.
///
/// If the function is used asynchronously, a return value of ERROR_IO_PENDING indicates that the cache request is queued and completes
/// later through normal overlapped I/O completion mechanisms.
///
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters is in an unusable form.
///
/// -
/// ERROR_MORE_DATA
///
/// The buffer pointed to by pBuffer is too small to receive all the requested data; the size of buffer required is pointed to by
/// pBytesRead unless it was NULL or the call was asynchronous. In the case of an asynchronous call, the value pointed to
/// by the lpNumberOfBytesTransferred parameter of the GetOverLappedResult function is set to the buffer size required.
///
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpreadfragmentfromcache HTTPAPI_LINKAGE ULONG
// HttpReadFragmentFromCache( [in] HANDLE RequestQueueHandle, [in] PCWSTR UrlPrefix, [in] PHTTP_BYTE_RANGE ByteRange, [out] PVOID Buffer,
// [in] ULONG BufferLength, [out] PULONG BytesRead, [in] LPOVERLAPPED Overlapped );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpReadFragmentFromCache")]
public static extern Win32Error HttpReadFragmentFromCache([In] HREQQUEUEv1 RequestQueueHandle, [MarshalAs(UnmanagedType.LPWStr)] string UrlPrefix,
[In, Optional] IntPtr ByteRange, [Out] IntPtr Buffer, [In] uint BufferLength, out uint BytesRead, [In, Optional] IntPtr Overlapped);
///
/// The HttpReceiveClientCertificate function is used by a server application to retrieve a client SSL certificate or channel
/// binding token (CBT).
///
///
///
/// A handle to the request queue with which the specified SSL client or CBT is associated. A request queue is created and its handle
/// returned by a call to the HttpCreateRequestQueue function.
///
///
/// Windows Server 2003 with SP1 and Windows XP with SP2: The handle to the request queue is created by the HttpCreateHttpHandle function.
///
///
///
/// A value that identifies the connection to the client. This value is obtained from the ConnectionId element of an HTTP_REQUEST
/// structure filled in by the HttpReceiveHttpRequest function.
///
///
/// A value that modifies the behavior of the HttpReceiveClientCertificate function
///
///
/// Value
/// Meaning
///
/// -
/// HTTP_RECEIVE_SECURE_CHANNEL_TOKEN 0x1
///
/// The pSslClientCertInfo parameter will be populated with CBT data. This value is supported on Windows 7, Windows Server 2008
/// R2, and later.
///
///
///
///
///
///
/// If the Flags parameter is 0, then this parameter points to an HTTP_SSL_CLIENT_CERT_INFO structure into which the function
/// writes the requested client certificate information. The buffer pointed to by the pSslClientCertInfo should be sufficiently
/// large enough to hold the HTTP_SSL_CLIENT_CERT_INFO structure plus the value of the CertEncodedSize member of this structure.
///
///
/// If the Flags parameter is HTTP_RECEIVE_SECURE_CHANNEL_TOKEN, then this parameter points to an
/// HTTP_REQUEST_CHANNEL_BIND_STATUS structure into which the function writes the requested CBT information. The buffer pointed to by the
/// pSslClientCertInfo should be sufficiently large enough to hold the HTTP_REQUEST_CHANNEL_BIND_STATUS structure plus the
/// value of the ChannelTokenSize member of this structure.
///
///
/// The size, in bytes, of the buffer pointed to by the pSslClientCertInfo parameter.
///
///
/// An optional pointer to a variable that receives the number of bytes to be written to the structure pointed to by
/// pSslClientCertInfo. If not used, set it to NULL.
///
///
/// When making an asynchronous call using pOverlapped, set pBytesReceived to NULL. Otherwise, when
/// pOverlapped is set to NULL, pBytesReceived must contain a valid memory address, and not be set to NULL.
///
///
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure, or for synchronous calls, set it to NULL.
///
/// A synchronous call blocks until the client certificate is retrieved, whereas an asynchronous call immediately returns
/// ERROR_IO_PENDING and the calling application then uses GetOverlappedResult or I/O completion ports to determine when the
/// operation is completed. For more information about using OVERLAPPED structures for synchronization, see the section Synchronization
/// and Overlapped Input and Output.
///
///
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_ERROR
///
/// The function succeeded. All the data has been written into the buffer pointed to by the pSslClientCertInfo parameter. The
/// NumberOfBytesTransferred indicates how many bytes were written into the buffer.
///
///
/// -
/// ERROR_IO_PENDING
///
/// The function is being used asynchronously. The operation has been initiated and will complete later through normal overlapped I/O
/// completion mechanisms.
///
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters is not valid.
///
/// -
/// ERROR_INSUFFICIENT_BUFFER
/// The buffer pointed to by the pSslClientCertInfo parameter is too small to receive the data and no data was written.
///
/// -
/// ERROR_MORE_DATA
///
/// The buffer pointed to by the pSslClientCertInfo parameter is not large enough to receive all the data. Only the basic
/// structure has been written and only partially populated. When the Flags parameter is 0, the HTTP_SSL_CLIENT_CERT_INFO
/// structure has been written with the CertEncodedSize member populated. The caller should call the function again with a buffer
/// that is at least the size, in bytes, of the HTTP_SSL_CLIENT_CERT_INFO structure plus the value of the CertEncodedSize
/// member. When the Flags parameter is HTTP_RECEIVE_SECURE_CHANNEL_TOKEN, the HTTP_REQUEST_CHANNEL_BIND_STATUS structure
/// has been written with the ChannelTokenSize member populated. The caller should call the function again with a buffer that is
/// at least the size, in bytes, of the HTTP_REQUEST_CHANNEL_BIND_STATUS plus the value of the ChannelTokenSize member.
///
///
/// -
/// ERROR_NOT_FOUND
/// The function cannot find the client certificate or CBT.
///
/// -
/// Other
/// A system error code defined in the WinError.h header file.
///
///
///
///
///
/// The behavior of the HttpReceiveClientCertificate function varies based on whether a client SSL certificate or a channel
/// binding token is requested.
///
///
/// In the case of a synchronous call to the HttpReceiveClientCertificate function , the number of bytes received is returned in
/// the value pointed to by the pBytesReceived parameter.
///
///
/// In the case of an asynchronous call to the HttpReceiveClientCertificate function, the number of bytes received is returned by
/// the standard mechanisms used for asynchronous calls. The lpNumberOfBytesTransferred parameter returned by the
/// GetOverlappedResult function contains the number of bytes received.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpreceiveclientcertificate HTTPAPI_LINKAGE ULONG
// HttpReceiveClientCertificate( [in] HANDLE RequestQueueHandle, [in] HTTP_CONNECTION_ID ConnectionId, [in] ULONG Flags, [out]
// PHTTP_SSL_CLIENT_CERT_INFO SslClientCertInfo, [in] ULONG SslClientCertInfoSize, [out, optional] PULONG BytesReceived, [in, optional]
// LPOVERLAPPED Overlapped );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpReceiveClientCertificate")]
public static extern Win32Error HttpReceiveClientCertificate([In] HREQQUEUEv1 RequestQueueHandle, [In] HTTP_CONNECTION_ID ConnectionId,
[In] HTTP_RECEIVE Flags, [Out] IntPtr SslClientCertInfo, [In] uint SslClientCertInfoSize, out uint BytesReceived, in NativeOverlapped Overlapped);
///
/// The HttpReceiveClientCertificate function is used by a server application to retrieve a client SSL certificate or channel
/// binding token (CBT).
///
///
///
/// A handle to the request queue with which the specified SSL client or CBT is associated. A request queue is created and its handle
/// returned by a call to the HttpCreateRequestQueue function.
///
///
/// Windows Server 2003 with SP1 and Windows XP with SP2: The handle to the request queue is created by the HttpCreateHttpHandle function.
///
///
///
/// A value that identifies the connection to the client. This value is obtained from the ConnectionId element of an HTTP_REQUEST
/// structure filled in by the HttpReceiveHttpRequest function.
///
///
/// A value that modifies the behavior of the HttpReceiveClientCertificate function
///
///
/// Value
/// Meaning
///
/// -
/// HTTP_RECEIVE_SECURE_CHANNEL_TOKEN 0x1
///
/// The pSslClientCertInfo parameter will be populated with CBT data. This value is supported on Windows 7, Windows Server 2008
/// R2, and later.
///
///
///
///
///
///
/// If the Flags parameter is 0, then this parameter points to an HTTP_SSL_CLIENT_CERT_INFO structure into which the function
/// writes the requested client certificate information. The buffer pointed to by the pSslClientCertInfo should be sufficiently
/// large enough to hold the HTTP_SSL_CLIENT_CERT_INFO structure plus the value of the CertEncodedSize member of this structure.
///
///
/// If the Flags parameter is HTTP_RECEIVE_SECURE_CHANNEL_TOKEN, then this parameter points to an
/// HTTP_REQUEST_CHANNEL_BIND_STATUS structure into which the function writes the requested CBT information. The buffer pointed to by the
/// pSslClientCertInfo should be sufficiently large enough to hold the HTTP_REQUEST_CHANNEL_BIND_STATUS structure plus the
/// value of the ChannelTokenSize member of this structure.
///
///
/// The size, in bytes, of the buffer pointed to by the pSslClientCertInfo parameter.
///
///
/// An optional pointer to a variable that receives the number of bytes to be written to the structure pointed to by
/// pSslClientCertInfo. If not used, set it to NULL.
///
///
/// When making an asynchronous call using pOverlapped, set pBytesReceived to NULL. Otherwise, when
/// pOverlapped is set to NULL, pBytesReceived must contain a valid memory address, and not be set to NULL.
///
///
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure, or for synchronous calls, set it to NULL.
///
/// A synchronous call blocks until the client certificate is retrieved, whereas an asynchronous call immediately returns
/// ERROR_IO_PENDING and the calling application then uses GetOverlappedResult or I/O completion ports to determine when the
/// operation is completed. For more information about using OVERLAPPED structures for synchronization, see the section Synchronization
/// and Overlapped Input and Output.
///
///
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_ERROR
///
/// The function succeeded. All the data has been written into the buffer pointed to by the pSslClientCertInfo parameter. The
/// NumberOfBytesTransferred indicates how many bytes were written into the buffer.
///
///
/// -
/// ERROR_IO_PENDING
///
/// The function is being used asynchronously. The operation has been initiated and will complete later through normal overlapped I/O
/// completion mechanisms.
///
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters is not valid.
///
/// -
/// ERROR_INSUFFICIENT_BUFFER
/// The buffer pointed to by the pSslClientCertInfo parameter is too small to receive the data and no data was written.
///
/// -
/// ERROR_MORE_DATA
///
/// The buffer pointed to by the pSslClientCertInfo parameter is not large enough to receive all the data. Only the basic
/// structure has been written and only partially populated. When the Flags parameter is 0, the HTTP_SSL_CLIENT_CERT_INFO
/// structure has been written with the CertEncodedSize member populated. The caller should call the function again with a buffer
/// that is at least the size, in bytes, of the HTTP_SSL_CLIENT_CERT_INFO structure plus the value of the CertEncodedSize
/// member. When the Flags parameter is HTTP_RECEIVE_SECURE_CHANNEL_TOKEN, the HTTP_REQUEST_CHANNEL_BIND_STATUS structure
/// has been written with the ChannelTokenSize member populated. The caller should call the function again with a buffer that is
/// at least the size, in bytes, of the HTTP_REQUEST_CHANNEL_BIND_STATUS plus the value of the ChannelTokenSize member.
///
///
/// -
/// ERROR_NOT_FOUND
/// The function cannot find the client certificate or CBT.
///
/// -
/// Other
/// A system error code defined in the WinError.h header file.
///
///
///
///
///
/// The behavior of the HttpReceiveClientCertificate function varies based on whether a client SSL certificate or a channel
/// binding token is requested.
///
///
/// In the case of a synchronous call to the HttpReceiveClientCertificate function , the number of bytes received is returned in
/// the value pointed to by the pBytesReceived parameter.
///
///
/// In the case of an asynchronous call to the HttpReceiveClientCertificate function, the number of bytes received is returned by
/// the standard mechanisms used for asynchronous calls. The lpNumberOfBytesTransferred parameter returned by the
/// GetOverlappedResult function contains the number of bytes received.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpreceiveclientcertificate HTTPAPI_LINKAGE ULONG
// HttpReceiveClientCertificate( [in] HANDLE RequestQueueHandle, [in] HTTP_CONNECTION_ID ConnectionId, [in] ULONG Flags, [out]
// PHTTP_SSL_CLIENT_CERT_INFO SslClientCertInfo, [in] ULONG SslClientCertInfoSize, [out, optional] PULONG BytesReceived, [in, optional]
// LPOVERLAPPED Overlapped );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpReceiveClientCertificate")]
public static extern Win32Error HttpReceiveClientCertificate([In] HREQQUEUEv1 RequestQueueHandle, [In] HTTP_CONNECTION_ID ConnectionId,
[In] HTTP_RECEIVE Flags, [Out] IntPtr SslClientCertInfo, [In] uint SslClientCertInfoSize, out uint BytesReceived, [In, Optional] IntPtr Overlapped);
///
/// The HttpReceiveHttpRequest function retrieves the next available HTTP request from the specified request queue either
/// synchronously or asynchronously.
///
///
///
/// A handle to the request queue from which to retrieve the next available request. A request queue is created and its handle returned
/// by a call to the HttpCreateRequestQueue function.
///
///
/// Windows Server 2003 with SP1 and Windows XP with SP2: The handle to the request queue is created by the HttpCreateHttpHandle function.
///
///
///
/// On the first call to retrieve a request, this parameter should be HTTP_NULL_ID. Then, if more than one call is required to
/// retrieve the entire request, HttpReceiveHttpRequest or HttpReceiveRequestEntityBody can be called with RequestID set to
/// the value returned in the RequestId member of the HTTP_REQUEST structure pointed to by pRequestBuffer.
///
///
/// A parameter that can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// 0 (zero)
/// Only the request headers are retrieved; the entity body is not copied.
///
/// -
/// HTTP_RECEIVE_REQUEST_FLAG_COPY_BODY
///
/// The available entity body is copied along with the request headers. The pEntityChunks member of the HTTP_REQUEST structure
/// points to the entity body.
///
///
/// -
/// HTTP_RECEIVE_REQUEST_FLAG_FLUSH_BODY
///
/// All of the entity bodies are copied along with the request headers. The pEntityChunks member of the HTTP_REQUEST structure
/// points to the entity body.
///
///
///
///
///
/// A pointer to a buffer into which the function copies an HTTP_REQUEST structure and entity body for the HTTP request.
/// HTTP_REQUEST.RequestId contains the identifier for this HTTP request, which the application can use in subsequent calls
/// HttpReceiveRequestEntityBody, HttpSendHttpResponse, or HttpSendResponseEntityBody.
///
/// Size, in bytes, of the pRequestBuffer buffer.
///
///
/// Optional. A pointer to a variable that receives the size, in bytes, of the entity body, or of the remaining part of the entity body.
///
///
/// When making an asynchronous call using pOverlapped, set pBytesReceived to NULL. Otherwise, when
/// pOverlapped is set to NULL, pBytesReceived must contain a valid memory address, and not be set to NULL.
///
///
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure; for synchronous calls, set it to NULL.
///
/// A synchronous call blocks until a request has arrived in the specified queue and some or all of it has been retrieved, whereas an
/// asynchronous call immediately returns ERROR_IO_PENDING and the calling application then uses GetOverlappedResult or I/O
/// completion ports to determine when the operation is completed. For more information about using OVERLAPPED structures for
/// synchronization, see Synchronization and Overlapped Input and Output.
///
///
///
/// If the function succeeds, the return value is NO_ERROR.
///
/// If the function is being used asynchronously, a return value of ERROR_IO_PENDING indicates that the next request is not yet
/// ready and will be retrieved later through normal overlapped I/O completion mechanisms.
///
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters is in an unusable form.
///
/// -
/// ERROR_NOACCESS
///
/// One or more of the supplied parameters points to an invalid or unaligned memory buffer. The pRequestBuffer parameter must
/// point to a valid memory buffer with a memory alignment equal or greater to the memory alignment requirement for an
/// HTTP_REQUEST structure.
///
///
/// -
/// ERROR_MORE_DATA
///
/// The value of RequestBufferLength is greater than or equal to the size of the request header received, but is not as large as
/// the combined size of the request structure and entity body. The buffer size required to read the remaining part of the entity body is
/// returned in the pBytesReceived parameter if this is non- NULL and if the call is synchronous. Call the function again
/// with a large enough buffer to retrieve all data.
///
///
/// -
/// ERROR_HANDLE_EOF
///
/// The specified request has already been completely retrieved; in this case, the value pointed to by pBytesReceived is not
/// meaningful, and pRequestBuffer should not be examined.
///
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
///
///
/// More than one call can be required to retrieve a given request. When the Flags parameter is set to zero, for example,
/// HttpReceiveHttpRequest only copies the request header structure into the buffer, and does not attempt to copy any of the
/// entity body. In this case, the HttpReceiveRequestEntityBody function can be used to retrieve the entity body, or a second call can be
/// made to HttpReceiveHttpRequest.
///
///
/// Alternatively, the buffer provided by the application may be insufficiently large to receive all or part of the request. To be sure
/// of receiving at least part of the request, it is recommended that an application provide at least a buffer of 4 KB, which
/// accommodates most HTTP requests. Alternately, authentication headers, parsed as unknown headers, can add up to 12 KB to that, so if
/// authentication/authorization is used, a buffer size of at least 16 KB is recommended.
///
///
/// If HttpReceiveHttpRequest returns ERROR_MORE_DATA, the application continues to make additional calls, identifying the
/// request in each additional call by passing in the HTTP_REQUEST.RequestId value returned by the first call until
/// ERROR_HANDLE_EOF is returned.
///
///
/// Note The application must examine all relevant request headers, including content-negotiation headers if used, and fail the
/// request as appropriate based on the header content. HttpReceiveHttpRequest ensures only that the header line is properly
/// terminated and does not contain illegal characters.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpreceivehttprequest HTTPAPI_LINKAGE ULONG HttpReceiveHttpRequest(
// [in] HANDLE RequestQueueHandle, [in] HTTP_REQUEST_ID RequestId, [in] ULONG Flags, [out] PHTTP_REQUEST RequestBuffer, [in] ULONG
// RequestBufferLength, [out, optional] PULONG BytesReturned, [in, optional] LPOVERLAPPED Overlapped );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpReceiveHttpRequest")]
public static extern Win32Error HttpReceiveHttpRequest([In] HREQQUEUEv1 RequestQueueHandle, [In] HTTP_REQUEST_ID RequestId,
[In] HTTP_RECEIVE_REQUEST_FLAG Flags, [Out] IntPtr RequestBuffer, [In] uint RequestBufferLength, out uint BytesReturned, in NativeOverlapped Overlapped);
///
/// The HttpReceiveHttpRequest function retrieves the next available HTTP request from the specified request queue either
/// synchronously or asynchronously.
///
///
///
/// A handle to the request queue from which to retrieve the next available request. A request queue is created and its handle returned
/// by a call to the HttpCreateRequestQueue function.
///
///
/// Windows Server 2003 with SP1 and Windows XP with SP2: The handle to the request queue is created by the HttpCreateHttpHandle function.
///
///
///
/// On the first call to retrieve a request, this parameter should be HTTP_NULL_ID. Then, if more than one call is required to
/// retrieve the entire request, HttpReceiveHttpRequest or HttpReceiveRequestEntityBody can be called with RequestID set to
/// the value returned in the RequestId member of the HTTP_REQUEST structure pointed to by pRequestBuffer.
///
///
/// A parameter that can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// 0 (zero)
/// Only the request headers are retrieved; the entity body is not copied.
///
/// -
/// HTTP_RECEIVE_REQUEST_FLAG_COPY_BODY
///
/// The available entity body is copied along with the request headers. The pEntityChunks member of the HTTP_REQUEST structure
/// points to the entity body.
///
///
/// -
/// HTTP_RECEIVE_REQUEST_FLAG_FLUSH_BODY
///
/// All of the entity bodies are copied along with the request headers. The pEntityChunks member of the HTTP_REQUEST structure
/// points to the entity body.
///
///
///
///
///
/// A pointer to a buffer into which the function copies an HTTP_REQUEST structure and entity body for the HTTP request.
/// HTTP_REQUEST.RequestId contains the identifier for this HTTP request, which the application can use in subsequent calls
/// HttpReceiveRequestEntityBody, HttpSendHttpResponse, or HttpSendResponseEntityBody.
///
/// Size, in bytes, of the pRequestBuffer buffer.
///
///
/// Optional. A pointer to a variable that receives the size, in bytes, of the entity body, or of the remaining part of the entity body.
///
///
/// When making an asynchronous call using pOverlapped, set pBytesReceived to NULL. Otherwise, when
/// pOverlapped is set to NULL, pBytesReceived must contain a valid memory address, and not be set to NULL.
///
///
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure; for synchronous calls, set it to NULL.
///
/// A synchronous call blocks until a request has arrived in the specified queue and some or all of it has been retrieved, whereas an
/// asynchronous call immediately returns ERROR_IO_PENDING and the calling application then uses GetOverlappedResult or I/O
/// completion ports to determine when the operation is completed. For more information about using OVERLAPPED structures for
/// synchronization, see Synchronization and Overlapped Input and Output.
///
///
///
/// If the function succeeds, the return value is NO_ERROR.
///
/// If the function is being used asynchronously, a return value of ERROR_IO_PENDING indicates that the next request is not yet
/// ready and will be retrieved later through normal overlapped I/O completion mechanisms.
///
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters is in an unusable form.
///
/// -
/// ERROR_NOACCESS
///
/// One or more of the supplied parameters points to an invalid or unaligned memory buffer. The pRequestBuffer parameter must
/// point to a valid memory buffer with a memory alignment equal or greater to the memory alignment requirement for an
/// HTTP_REQUEST structure.
///
///
/// -
/// ERROR_MORE_DATA
///
/// The value of RequestBufferLength is greater than or equal to the size of the request header received, but is not as large as
/// the combined size of the request structure and entity body. The buffer size required to read the remaining part of the entity body is
/// returned in the pBytesReceived parameter if this is non- NULL and if the call is synchronous. Call the function again
/// with a large enough buffer to retrieve all data.
///
///
/// -
/// ERROR_HANDLE_EOF
///
/// The specified request has already been completely retrieved; in this case, the value pointed to by pBytesReceived is not
/// meaningful, and pRequestBuffer should not be examined.
///
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
///
///
/// More than one call can be required to retrieve a given request. When the Flags parameter is set to zero, for example,
/// HttpReceiveHttpRequest only copies the request header structure into the buffer, and does not attempt to copy any of the
/// entity body. In this case, the HttpReceiveRequestEntityBody function can be used to retrieve the entity body, or a second call can be
/// made to HttpReceiveHttpRequest.
///
///
/// Alternatively, the buffer provided by the application may be insufficiently large to receive all or part of the request. To be sure
/// of receiving at least part of the request, it is recommended that an application provide at least a buffer of 4 KB, which
/// accommodates most HTTP requests. Alternately, authentication headers, parsed as unknown headers, can add up to 12 KB to that, so if
/// authentication/authorization is used, a buffer size of at least 16 KB is recommended.
///
///
/// If HttpReceiveHttpRequest returns ERROR_MORE_DATA, the application continues to make additional calls, identifying the
/// request in each additional call by passing in the HTTP_REQUEST.RequestId value returned by the first call until
/// ERROR_HANDLE_EOF is returned.
///
///
/// Note The application must examine all relevant request headers, including content-negotiation headers if used, and fail the
/// request as appropriate based on the header content. HttpReceiveHttpRequest ensures only that the header line is properly
/// terminated and does not contain illegal characters.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpreceivehttprequest HTTPAPI_LINKAGE ULONG HttpReceiveHttpRequest(
// [in] HANDLE RequestQueueHandle, [in] HTTP_REQUEST_ID RequestId, [in] ULONG Flags, [out] PHTTP_REQUEST RequestBuffer, [in] ULONG
// RequestBufferLength, [out, optional] PULONG BytesReturned, [in, optional] LPOVERLAPPED Overlapped );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpReceiveHttpRequest")]
public static extern Win32Error HttpReceiveHttpRequest([In] HREQQUEUEv1 RequestQueueHandle, [In] HTTP_REQUEST_ID RequestId,
[In] HTTP_RECEIVE_REQUEST_FLAG Flags, [Out] IntPtr RequestBuffer, [In] uint RequestBufferLength, out uint BytesReturned, [In, Optional] IntPtr Overlapped);
///
/// The HttpReceiveHttpRequest function retrieves the next available HTTP request from the specified request queue either
/// synchronously or asynchronously.
///
///
///
/// A handle to the request queue from which to retrieve the next available request. A request queue is created and its handle returned
/// by a call to the HttpCreateRequestQueue function.
///
///
/// Windows Server 2003 with SP1 and Windows XP with SP2: The handle to the request queue is created by the HttpCreateHttpHandle function.
///
///
///
/// On the first call to retrieve a request, this parameter should be HTTP_NULL_ID. Then, if more than one call is required to
/// retrieve the entire request, HttpReceiveHttpRequest or HttpReceiveRequestEntityBody can be called with RequestID set to
/// the value returned in the RequestId member of the HTTP_REQUEST structure pointed to by pRequestBuffer.
///
///
/// A parameter that can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// 0 (zero)
/// Only the request headers are retrieved; the entity body is not copied.
///
/// -
/// HTTP_RECEIVE_REQUEST_FLAG_COPY_BODY
///
/// The available entity body is copied along with the request headers. The pEntityChunks member of the HTTP_REQUEST structure
/// points to the entity body.
///
///
/// -
/// HTTP_RECEIVE_REQUEST_FLAG_FLUSH_BODY
///
/// All of the entity bodies are copied along with the request headers. The pEntityChunks member of the HTTP_REQUEST structure
/// points to the entity body.
///
///
///
///
///
/// An HTTP_REQUEST structure and entity body for the HTTP request. HTTP_REQUEST.RequestId contains the identifier for this HTTP
/// request, which the application can use in subsequent calls HttpReceiveRequestEntityBody, HttpSendHttpResponse, or HttpSendResponseEntityBody.
///
///
/// If the function succeeds, the return value is NO_ERROR.
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters is in an unusable form.
///
/// -
/// ERROR_NOACCESS
///
/// One or more of the supplied parameters points to an invalid or unaligned memory buffer. The pRequestBuffer parameter must
/// point to a valid memory buffer with a memory alignment equal or greater to the memory alignment requirement for an
/// HTTP_REQUEST structure.
///
///
/// -
/// ERROR_MORE_DATA
///
/// The value of RequestBufferLength is greater than or equal to the size of the request header received, but is not as large as
/// the combined size of the request structure and entity body. The buffer size required to read the remaining part of the entity body is
/// returned in the pBytesReceived parameter if this is non- NULL and if the call is synchronous. Call the function again
/// with a large enough buffer to retrieve all data.
///
///
/// -
/// ERROR_HANDLE_EOF
///
/// The specified request has already been completely retrieved; in this case, the value pointed to by pBytesReceived is not
/// meaningful, and pRequestBuffer should not be examined.
///
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
///
///
/// More than one call can be required to retrieve a given request. When the Flags parameter is set to zero, for example,
/// HttpReceiveHttpRequest only copies the request header structure into the buffer, and does not attempt to copy any of the
/// entity body. In this case, the HttpReceiveRequestEntityBody function can be used to retrieve the entity body, or a second call can be
/// made to HttpReceiveHttpRequest.
///
///
/// Alternatively, the buffer provided by the application may be insufficiently large to receive all or part of the request. To be sure
/// of receiving at least part of the request, it is recommended that an application provide at least a buffer of 4 KB, which
/// accommodates most HTTP requests. Alternately, authentication headers, parsed as unknown headers, can add up to 12 KB to that, so if
/// authentication/authorization is used, a buffer size of at least 16 KB is recommended.
///
///
/// If HttpReceiveHttpRequest returns ERROR_MORE_DATA, the application continues to make additional calls, identifying the
/// request in each additional call by passing in the HTTP_REQUEST.RequestId value returned by the first call until
/// ERROR_HANDLE_EOF is returned.
///
///
/// Note The application must examine all relevant request headers, including content-negotiation headers if used, and fail the
/// request as appropriate based on the header content. HttpReceiveHttpRequest ensures only that the header line is properly
/// terminated and does not contain illegal characters.
///
///
public static Win32Error HttpReceiveHttpRequest(HREQQUEUEv1 RequestQueueHandle, [In] HTTP_REQUEST_ID RequestId,
[In] HTTP_RECEIVE_REQUEST_FLAG Flags, out HTTP_REQUEST? RequestBuffer)
{
RequestBuffer = new();
var err = HttpReceiveHttpRequest(RequestQueueHandle, RequestId, Flags, RequestBuffer.Ptr, RequestBuffer.Ptr.Size, out var sz, default);
switch ((uint)err)
{
case Win32Error.ERROR_SUCCESS:
return Win32Error.ERROR_SUCCESS;
case Win32Error.ERROR_MORE_DATA:
RequestId = RequestBuffer.RequestId;
RequestBuffer.Ptr.Size = sz;
break;
case Win32Error.ERROR_CONNECTION_INVALID:
if (RequestId != HTTP_NULL_ID)
RequestId = HTTP_NULL_ID;
break;
default:
RequestBuffer = default;
return err;
}
err = HttpReceiveHttpRequest(RequestQueueHandle, RequestId, Flags, RequestBuffer.Ptr, RequestBuffer.Ptr.Size, out _, default);
return err;
}
/// The HttpReceiveRequestEntityBody function receives additional entity body data for a specified HTTP request.
///
///
/// The handle to the request queue from which to retrieve the specified entity body data. A request queue is created and its handle
/// returned by a call to the HttpCreateRequestQueue function.
///
///
/// Windows Server 2003 with SP1 and Windows XP with SP2: The handle to the request queue is created by the HttpCreateHttpHandle function.
///
///
///
/// The identifier of the HTTP request that contains the retrieved entity body. This value is returned in the RequestId member of
/// the HTTP_REQUEST structure by a call to the HttpReceiveHttpRequest function. This value cannot be HTTP_NULL_ID.
///
///
/// This parameter can be the following flag value.
/// Windows Server 2003 with SP1 and Windows XP with SP2: This parameter is reserved and must be zero.
///
///
/// Value
/// Meaning
///
/// -
/// HTTP_RECEIVE_REQUEST_ENTITY_BODY_FLAG_FILL_BUFFER
/// Specifies that the buffer will be filled with one or more entity bodies, unless there are no remaining entity bodies to copy.
///
///
///
/// A pointer to a buffer that receives entity-body data.
/// The size, in bytes, of the buffer pointed to by the pBuffer parameter.
///
///
/// Optional. A pointer to a variables that receives the size, in bytes, of the entity body data returned in the pBuffer buffer.
///
///
/// When making an asynchronous call using pOverlapped, set pBytesReceived to NULL. Otherwise, when
/// pOverlapped is set to NULL, pBytesReceived must contain a valid memory address, and not be set to NULL.
///
///
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure; for synchronous calls, set it to NULL.
///
/// A synchronous call blocks until the entity-body data has been retrieved, whereas an asynchronous call immediately returns
/// ERROR_IO_PENDING and the calling application then uses GetOverlappedResult or I/O completion ports to determine when the
/// operation is completed. For more information about using OVERLAPPED structures for synchronization, see Synchronization and
/// Overlapped Input and Output.
///
///
///
/// If the function succeeds, the return value is NO_ERROR.
///
/// If the function is used asynchronously, a return value of ERROR_IO_PENDING indicates that the next request is not yet ready
/// and is retrieved later through normal overlapped I/O completion mechanisms.
///
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters are in an unusable form.
///
/// -
/// ERROR_HANDLE_EOF
///
/// The specified entity body has already been completely retrieved; in this case, the value pointed to by pBytesReceived is not
/// meaningful, and pBuffer should not be examined.
///
///
/// -
/// ERROR_DLL_INIT_FAILED
/// The calling application did not call HttpInitialize before calling this function.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
///
/// To retrieve an entire entity body, an application is expected to call HttpReceiveRequestEntityBody, passing in new buffers,
/// until the function returns ERROR_HANDLE_EOF. As long as a buffer full of entity-body data is copied successfully and there is
/// still more entity-body data waiting to be retrieved, the function returns NO_ERROR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpreceiverequestentitybody HTTPAPI_LINKAGE ULONG
// HttpReceiveRequestEntityBody( [in] HANDLE RequestQueueHandle, [in] HTTP_REQUEST_ID RequestId, [in] ULONG Flags, [out] PVOID
// EntityBuffer, [in] ULONG EntityBufferLength, [out, optional] PULONG BytesReturned, [in, optional] LPOVERLAPPED Overlapped );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpReceiveRequestEntityBody")]
public static extern Win32Error HttpReceiveRequestEntityBody([In] HREQQUEUEv1 RequestQueueHandle, [In] HTTP_REQUEST_ID RequestId,
[In] HTTP_RECEIVE_REQUEST_ENTITY_BODY_FLAG Flags, [Out] IntPtr EntityBuffer, [In] uint EntityBufferLength, [In, Optional] IntPtr BytesReturned,
in NativeOverlapped Overlapped);
/// The HttpReceiveRequestEntityBody function receives additional entity body data for a specified HTTP request.
///
///
/// The handle to the request queue from which to retrieve the specified entity body data. A request queue is created and its handle
/// returned by a call to the HttpCreateRequestQueue function.
///
///
/// Windows Server 2003 with SP1 and Windows XP with SP2: The handle to the request queue is created by the HttpCreateHttpHandle function.
///
///
///
/// The identifier of the HTTP request that contains the retrieved entity body. This value is returned in the RequestId member of
/// the HTTP_REQUEST structure by a call to the HttpReceiveHttpRequest function. This value cannot be HTTP_NULL_ID.
///
///
/// This parameter can be the following flag value.
/// Windows Server 2003 with SP1 and Windows XP with SP2: This parameter is reserved and must be zero.
///
///
/// Value
/// Meaning
///
/// -
/// HTTP_RECEIVE_REQUEST_ENTITY_BODY_FLAG_FILL_BUFFER
/// Specifies that the buffer will be filled with one or more entity bodies, unless there are no remaining entity bodies to copy.
///
///
///
/// A pointer to a buffer that receives entity-body data.
/// The size, in bytes, of the buffer pointed to by the pBuffer parameter.
///
///
/// Optional. A pointer to a variables that receives the size, in bytes, of the entity body data returned in the pBuffer buffer.
///
///
/// When making an asynchronous call using pOverlapped, set pBytesReceived to NULL. Otherwise, when
/// pOverlapped is set to NULL, pBytesReceived must contain a valid memory address, and not be set to NULL.
///
///
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure; for synchronous calls, set it to NULL.
///
/// A synchronous call blocks until the entity-body data has been retrieved, whereas an asynchronous call immediately returns
/// ERROR_IO_PENDING and the calling application then uses GetOverlappedResult or I/O completion ports to determine when the
/// operation is completed. For more information about using OVERLAPPED structures for synchronization, see Synchronization and
/// Overlapped Input and Output.
///
///
///
/// If the function succeeds, the return value is NO_ERROR.
///
/// If the function is used asynchronously, a return value of ERROR_IO_PENDING indicates that the next request is not yet ready
/// and is retrieved later through normal overlapped I/O completion mechanisms.
///
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters are in an unusable form.
///
/// -
/// ERROR_HANDLE_EOF
///
/// The specified entity body has already been completely retrieved; in this case, the value pointed to by pBytesReceived is not
/// meaningful, and pBuffer should not be examined.
///
///
/// -
/// ERROR_DLL_INIT_FAILED
/// The calling application did not call HttpInitialize before calling this function.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
///
/// To retrieve an entire entity body, an application is expected to call HttpReceiveRequestEntityBody, passing in new buffers,
/// until the function returns ERROR_HANDLE_EOF. As long as a buffer full of entity-body data is copied successfully and there is
/// still more entity-body data waiting to be retrieved, the function returns NO_ERROR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpreceiverequestentitybody HTTPAPI_LINKAGE ULONG
// HttpReceiveRequestEntityBody( [in] HANDLE RequestQueueHandle, [in] HTTP_REQUEST_ID RequestId, [in] ULONG Flags, [out] PVOID
// EntityBuffer, [in] ULONG EntityBufferLength, [out, optional] PULONG BytesReturned, [in, optional] LPOVERLAPPED Overlapped );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpReceiveRequestEntityBody")]
public static extern Win32Error HttpReceiveRequestEntityBody([In] HREQQUEUEv1 RequestQueueHandle, [In] HTTP_REQUEST_ID RequestId,
[In] HTTP_RECEIVE_REQUEST_ENTITY_BODY_FLAG Flags, [Out] IntPtr EntityBuffer, [In] uint EntityBufferLength, out uint BytesReturned,
[In, Optional] IntPtr Overlapped);
///
///
/// The HttpRemoveUrl function causes the system to stop routing requests that match a specified UrlPrefix string to a specified
/// request queue.
///
///
/// Starting with HTTP Server API Version 2.0, applications should call HttpRemoveUrlFromUrlGroup to register a URL; HttpRemoveUrl
/// should not be used.
///
///
///
///
/// The handle to the request queue from which the URL registration is to be removed. A request queue is created and its handle returned
/// by a call to the HttpCreateRequestQueue function.
///
///
/// Windows Server 2003 with SP1 and Windows XP with SP2: The handle to the request queue is created by the HttpCreateHttpHandle function.
///
///
///
/// A pointer to a UrlPrefix string registered to the specified request queue. This string must be identical to the one passed to
/// HttpAddUrl to register the UrlPrefix; even a nomenclature change in an IPv6 address is not accepted.
///
///
/// If the function succeeds, the return value is NO_ERROR.
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_ACCESS_DENIED
/// The calling application does not have permission to remove the URL.
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters is in an unusable form.
///
/// -
/// ERROR_NOT_ENOUGH_MEMORY
/// Insufficient resources to complete the operation.
///
/// -
/// ERROR_FILE_NOT_FOUND
/// The specified UrlPrefix could not be found in the registration database.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpremoveurl HTTPAPI_LINKAGE ULONG HttpRemoveUrl( [in] HANDLE
// RequestQueueHandle, [in] PCWSTR FullyQualifiedUrl );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpRemoveUrl")]
public static extern Win32Error HttpRemoveUrl([In] HREQQUEUEv1 RequestQueueHandle, [MarshalAs(UnmanagedType.LPWStr)] string FullyQualifiedUrl);
///
///
/// The HttpRemoveUrlFromUrlGroup function removes the specified URL from the group identified by the URL Group ID. This function
/// removes one, or all, of the URLs from the group.
///
/// This function replaces the HTTP version 1.0 HttpRemoveUrl function.
///
/// The ID of the URL group from which the URL specified in pFullyQualifiedUrl is removed.
///
/// A pointer to a Unicode string that contains a properly formed UrlPrefix String that identifies the URL to be removed.
///
/// When HTTP_URL_FLAG_REMOVE_ALL is passed in the Flags parameter, all of the existing URL registrations for the URL Group
/// identified in UrlGroupId are removed from the group. In this case, pFullyQualifiedUrl must be NULL.
///
///
///
/// The URL flags qualifying the URL that is removed. This can be one of the following flags:
///
///
/// URL Flag
/// Meaning
///
/// -
/// HTTP_URL_FLAG_REMOVE_ALL
/// Removes all of the URLs currently registered with the URL Group.
///
///
///
///
/// If the function succeeds, it returns NO_ERROR.
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
///
/// The URL Group does not exist. The Flags parameter contains an invalid combination of flags. The HTTP_URL_FLAG_REMOVE_ALL flag was set
/// and the pFullyQualifiedUrl parameter was not set to NULL. The application does not have permission to remove URLs from
/// the Group. Only the application that created the URL Group can remove URLs.
///
///
/// -
/// ERROR_ACCESS_DENIED
/// The calling process does not have permission to deregister the URL.
///
/// -
/// ERROR_FILE_NOT_FOUND
/// The specified URL is not registered with the URL Group.
///
///
///
///
///
/// The HTTP Server API supports existing applications using the version 1.0 URL registrations, however, new development with the HTTP
/// Server API should use HttpRemoveUrlFromUrlGroup; do not use HttpRemoveUrl.
///
/// Applications should remove the URL added to the group by HttpAddUrlToUrlGroup, when the URL is no longer required.
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpremoveurlfromurlgroup HTTPAPI_LINKAGE ULONG
// HttpRemoveUrlFromUrlGroup( [in] HTTP_URL_GROUP_ID UrlGroupId, [in] PCWSTR pFullyQualifiedUrl, [in] ULONG Flags );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpRemoveUrlFromUrlGroup")]
public static extern Win32Error HttpRemoveUrlFromUrlGroup([In] HTTP_URL_GROUP_ID UrlGroupId, [MarshalAs(UnmanagedType.LPWStr)] string? pFullyQualifiedUrl,
[In, Optional] HTTP_URL_FLAG Flags);
/// The HttpSendHttpResponse function sends an HTTP response to the specified HTTP request.
///
///
/// A handle to the request queue from which the specified request was retrieved. A request queue is created and its handle returned by a
/// call to the HttpCreateRequestQueue function.
///
///
/// Windows Server 2003 with SP1 and Windows XP with SP2: The handle to the request queue is created by the HttpCreateHttpHandle function.
///
///
///
/// An identifier of the HTTP request to which this response corresponds. This value is returned in the RequestId member of the
/// HTTP_REQUEST structure by a call to the HttpReceiveHttpRequest function. This value cannot be HTTP_NULL_ID.
///
///
/// This parameter can be a combination of some of the following flag values. Those that are mutually exclusive are marked accordingly.
///
///
/// Flags
/// Meaning
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_DISCONNECT
///
/// The network connection should be disconnected after sending this response, overriding any persistent connection features associated
/// with the version of HTTP in use.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_MORE_DATA
///
/// Additional entity body data for this response is sent by the application through one or more subsequent calls to
/// HttpSendResponseEntityBody. The last call sending entity-body data then sets this flag to zero.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_BUFFER_DATA
///
/// This flag enables buffering of data in the kernel on a per-response basis. It should be used by an application doing synchronous I/O
/// or by an application doing asynchronous I/O with no more than one outstanding send at a time. Applications that use asynchronous I/O
/// and that may have more than one send outstanding at a time should not use this flag. When this flag is set, it should also be used
/// consistently in calls to the HttpSendResponseEntityBody function. Windows Server 2003: This flag is not supported. This flag
/// is new for Windows Server 2003 with SP1.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_ENABLE_NAGLING
///
/// Enables the TCP nagling algorithm for this send only. Windows Server 2003 with SP1 and Windows XP with SP2: This flag is not supported.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_PROCESS_RANGES
///
/// Specifies that for a range request, the full response content is passed and the caller wants the HTTP API to process ranges
/// appropriately. Windows Server 2008 R2 and Windows 7 or later. Note This flag is supported.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_OPAQUE
///
/// Specifies that the request/response is not HTTP compliant and all subsequent bytes should be treated as entity-body. Applications
/// specify this flag when it is accepting a Web Socket upgrade request and informing HTTP.sys to treat the connection data as opaque
/// data. This flag is only allowed when the StatusCode member of pHttpResponse is 101, switching protocols.
/// HttpSendHttpResponse returns ERROR_INVALID_PARAMETER for all other HTTP response types if this flag is used. Windows
/// 8 and later: This flag is supported.
///
///
///
///
/// A pointer to an HTTP_RESPONSE structure that defines the HTTP response.
///
/// A pointer to the HTTP_CACHE_POLICY structure used to cache the response.
/// Windows Server 2003 with SP1 and Windows XP with SP2: This parameter is reserved and must be NULL.
///
///
/// Optional. A pointer to a variable that receives the number, in bytes, sent if the function operates synchronously.
///
/// When making an asynchronous call using pOverlapped, set pBytesSent to NULL. Otherwise, when pOverlapped
/// is set to NULL, pBytesSent must contain a valid memory address and not be set to NULL.
///
///
/// This parameter is reserved and must be NULL.
/// This parameter is reserved and must be zero.
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure; for synchronous calls, set to NULL.
///
/// A synchronous call blocks until all response data specified in the pHttpResponse parameter is sent, whereas an asynchronous
/// call immediately returns ERROR_IO_PENDING and the calling application then uses GetOverlappedResult or I/O completion ports to
/// determine when the operation is completed. For more information about using OVERLAPPED structures for synchronization, see
/// Synchronization and Overlapped Input and Output.
///
///
///
///
/// A pointer to the HTTP_LOG_DATA structure used to log the response. Pass a pointer to the HTTP_LOG_FIELDS_DATA structure and cast it
/// to PHTTP_LOG_DATA.
///
///
/// Be aware that even when logging is enabled on a URL Group, or server session, the response will not be logged unless the application
/// supplies the log fields data structure.
///
/// Windows Server 2003 and Windows XP with SP2: This parameter is reserved and must be NULL.
/// Windows Vista and Windows Server 2008: This parameter is new for Windows Vista, and Windows Server 2008
///
///
/// If the function succeeds, the function returns NO_ERROR.
///
/// If the function is used asynchronously, a return value of ERROR_IO_PENDING indicates that the next request is not yet ready
/// and is retrieved later through normal overlapped I/O completion mechanisms.
///
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters is in an unusable form.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
///
///
/// The HttpSendHttpResponse function is used to create and send a response header, and the HttpSendResponseEntityBody function
/// can be used to send entity-body data as required.
///
///
/// If neither a content-length header nor a transfer-encoding header is included with the response, the application must indicate the
/// end of the response by explicitly closing the connection by using the HTTP_SEND_RESPONSE_DISCONNECT flag.
///
///
/// If an application specifies a "Server:" header in a response, using the HttpHeaderServer identifier in the HTTP_KNOWN_HEADER
/// structure, that specified value is placed as the first part of the header, followed by a space and then "Microsoft-HTTPAPI/1.0". If
/// no server header is specified, HttpSendHttpResponse supplies "Microsoft-HTTPAPI/1.0" as the server header.
///
///
/// Note The HttpSendHttpResponse and HttpSendResponseEntityBody function must not be called simultaneously from different
/// threads on the same RequestId.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpsendhttpresponse HTTPAPI_LINKAGE ULONG HttpSendHttpResponse( [in]
// HANDLE RequestQueueHandle, [in] HTTP_REQUEST_ID RequestId, [in] ULONG Flags, [in] PHTTP_RESPONSE HttpResponse, [in, optional]
// PHTTP_CACHE_POLICY CachePolicy, [out] PULONG BytesSent, [in] PVOID Reserved1, [in] ULONG Reserved2, [in] LPOVERLAPPED Overlapped, [in,
// optional] PHTTP_LOG_DATA LogData );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpSendHttpResponse")]
public static extern Win32Error HttpSendHttpResponse([In] HREQQUEUEv1 RequestQueueHandle, [In] HTTP_REQUEST_ID RequestId, [In] HTTP_SEND_RESPONSE_FLAG Flags,
in HTTP_RESPONSE_V1 HttpResponse, in HTTP_CACHE_POLICY CachePolicy, [Optional] IntPtr BytesSent, [In, Optional] IntPtr Reserved1, [In, Optional] uint Reserved2,
in NativeOverlapped Overlapped, in HTTP_LOG_DATA LogData);
/// The HttpSendHttpResponse function sends an HTTP response to the specified HTTP request.
///
///
/// A handle to the request queue from which the specified request was retrieved. A request queue is created and its handle returned by a
/// call to the HttpCreateRequestQueue function.
///
///
/// Windows Server 2003 with SP1 and Windows XP with SP2: The handle to the request queue is created by the HttpCreateHttpHandle function.
///
///
///
/// An identifier of the HTTP request to which this response corresponds. This value is returned in the RequestId member of the
/// HTTP_REQUEST structure by a call to the HttpReceiveHttpRequest function. This value cannot be HTTP_NULL_ID.
///
///
/// This parameter can be a combination of some of the following flag values. Those that are mutually exclusive are marked accordingly.
///
///
/// Flags
/// Meaning
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_DISCONNECT
///
/// The network connection should be disconnected after sending this response, overriding any persistent connection features associated
/// with the version of HTTP in use.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_MORE_DATA
///
/// Additional entity body data for this response is sent by the application through one or more subsequent calls to
/// HttpSendResponseEntityBody. The last call sending entity-body data then sets this flag to zero.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_BUFFER_DATA
///
/// This flag enables buffering of data in the kernel on a per-response basis. It should be used by an application doing synchronous I/O
/// or by an application doing asynchronous I/O with no more than one outstanding send at a time. Applications that use asynchronous I/O
/// and that may have more than one send outstanding at a time should not use this flag. When this flag is set, it should also be used
/// consistently in calls to the HttpSendResponseEntityBody function. Windows Server 2003: This flag is not supported. This flag
/// is new for Windows Server 2003 with SP1.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_ENABLE_NAGLING
///
/// Enables the TCP nagling algorithm for this send only. Windows Server 2003 with SP1 and Windows XP with SP2: This flag is not supported.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_PROCESS_RANGES
///
/// Specifies that for a range request, the full response content is passed and the caller wants the HTTP API to process ranges
/// appropriately. Windows Server 2008 R2 and Windows 7 or later. Note This flag is supported.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_OPAQUE
///
/// Specifies that the request/response is not HTTP compliant and all subsequent bytes should be treated as entity-body. Applications
/// specify this flag when it is accepting a Web Socket upgrade request and informing HTTP.sys to treat the connection data as opaque
/// data. This flag is only allowed when the StatusCode member of pHttpResponse is 101, switching protocols.
/// HttpSendHttpResponse returns ERROR_INVALID_PARAMETER for all other HTTP response types if this flag is used. Windows
/// 8 and later: This flag is supported.
///
///
///
///
/// A pointer to an HTTP_RESPONSE structure that defines the HTTP response.
///
/// A pointer to the HTTP_CACHE_POLICY structure used to cache the response.
/// Windows Server 2003 with SP1 and Windows XP with SP2: This parameter is reserved and must be NULL.
///
///
/// Optional. A pointer to a variable that receives the number, in bytes, sent if the function operates synchronously.
///
/// When making an asynchronous call using pOverlapped, set pBytesSent to NULL. Otherwise, when pOverlapped
/// is set to NULL, pBytesSent must contain a valid memory address and not be set to NULL.
///
///
/// This parameter is reserved and must be NULL.
/// This parameter is reserved and must be zero.
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure; for synchronous calls, set to NULL.
///
/// A synchronous call blocks until all response data specified in the pHttpResponse parameter is sent, whereas an asynchronous
/// call immediately returns ERROR_IO_PENDING and the calling application then uses GetOverlappedResult or I/O completion ports to
/// determine when the operation is completed. For more information about using OVERLAPPED structures for synchronization, see
/// Synchronization and Overlapped Input and Output.
///
///
///
///
/// A pointer to the HTTP_LOG_DATA structure used to log the response. Pass a pointer to the HTTP_LOG_FIELDS_DATA structure and cast it
/// to PHTTP_LOG_DATA.
///
///
/// Be aware that even when logging is enabled on a URL Group, or server session, the response will not be logged unless the application
/// supplies the log fields data structure.
///
/// Windows Server 2003 and Windows XP with SP2: This parameter is reserved and must be NULL.
/// Windows Vista and Windows Server 2008: This parameter is new for Windows Vista, and Windows Server 2008
///
///
/// If the function succeeds, the function returns NO_ERROR.
///
/// If the function is used asynchronously, a return value of ERROR_IO_PENDING indicates that the next request is not yet ready
/// and is retrieved later through normal overlapped I/O completion mechanisms.
///
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters is in an unusable form.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
///
///
/// The HttpSendHttpResponse function is used to create and send a response header, and the HttpSendResponseEntityBody function
/// can be used to send entity-body data as required.
///
///
/// If neither a content-length header nor a transfer-encoding header is included with the response, the application must indicate the
/// end of the response by explicitly closing the connection by using the HTTP_SEND_RESPONSE_DISCONNECT flag.
///
///
/// If an application specifies a "Server:" header in a response, using the HttpHeaderServer identifier in the HTTP_KNOWN_HEADER
/// structure, that specified value is placed as the first part of the header, followed by a space and then "Microsoft-HTTPAPI/1.0". If
/// no server header is specified, HttpSendHttpResponse supplies "Microsoft-HTTPAPI/1.0" as the server header.
///
///
/// Note The HttpSendHttpResponse and HttpSendResponseEntityBody function must not be called simultaneously from different
/// threads on the same RequestId.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpsendhttpresponse HTTPAPI_LINKAGE ULONG HttpSendHttpResponse( [in]
// HANDLE RequestQueueHandle, [in] HTTP_REQUEST_ID RequestId, [in] ULONG Flags, [in] PHTTP_RESPONSE HttpResponse, [in, optional]
// PHTTP_CACHE_POLICY CachePolicy, [out] PULONG BytesSent, [in] PVOID Reserved1, [in] ULONG Reserved2, [in] LPOVERLAPPED Overlapped, [in,
// optional] PHTTP_LOG_DATA LogData );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpSendHttpResponse")]
public static extern Win32Error HttpSendHttpResponse([In] HREQQUEUEv1 RequestQueueHandle, [In] HTTP_REQUEST_ID RequestId, [In] HTTP_SEND_RESPONSE_FLAG Flags,
in HTTP_RESPONSE_V1 HttpResponse, [In, Optional] IntPtr CachePolicy, out uint BytesSent, [In, Optional] IntPtr Reserved1, [In, Optional] uint Reserved2,
[In, Optional] IntPtr Overlapped, [In, Optional] IntPtr LogData);
/// The HttpSendHttpResponse function sends an HTTP response to the specified HTTP request.
///
///
/// A handle to the request queue from which the specified request was retrieved. A request queue is created and its handle returned by a
/// call to the HttpCreateRequestQueue function.
///
///
/// Windows Server 2003 with SP1 and Windows XP with SP2: The handle to the request queue is created by the HttpCreateHttpHandle function.
///
///
///
/// An identifier of the HTTP request to which this response corresponds. This value is returned in the RequestId member of the
/// HTTP_REQUEST structure by a call to the HttpReceiveHttpRequest function. This value cannot be HTTP_NULL_ID.
///
///
/// This parameter can be a combination of some of the following flag values. Those that are mutually exclusive are marked accordingly.
///
///
/// Flags
/// Meaning
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_DISCONNECT
///
/// The network connection should be disconnected after sending this response, overriding any persistent connection features associated
/// with the version of HTTP in use.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_MORE_DATA
///
/// Additional entity body data for this response is sent by the application through one or more subsequent calls to
/// HttpSendResponseEntityBody. The last call sending entity-body data then sets this flag to zero.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_BUFFER_DATA
///
/// This flag enables buffering of data in the kernel on a per-response basis. It should be used by an application doing synchronous I/O
/// or by an application doing asynchronous I/O with no more than one outstanding send at a time. Applications that use asynchronous I/O
/// and that may have more than one send outstanding at a time should not use this flag. When this flag is set, it should also be used
/// consistently in calls to the HttpSendResponseEntityBody function. Windows Server 2003: This flag is not supported. This flag
/// is new for Windows Server 2003 with SP1.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_ENABLE_NAGLING
///
/// Enables the TCP nagling algorithm for this send only. Windows Server 2003 with SP1 and Windows XP with SP2: This flag is not supported.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_PROCESS_RANGES
///
/// Specifies that for a range request, the full response content is passed and the caller wants the HTTP API to process ranges
/// appropriately. Windows Server 2008 R2 and Windows 7 or later. Note This flag is supported.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_OPAQUE
///
/// Specifies that the request/response is not HTTP compliant and all subsequent bytes should be treated as entity-body. Applications
/// specify this flag when it is accepting a Web Socket upgrade request and informing HTTP.sys to treat the connection data as opaque
/// data. This flag is only allowed when the StatusCode member of pHttpResponse is 101, switching protocols.
/// HttpSendHttpResponse returns ERROR_INVALID_PARAMETER for all other HTTP response types if this flag is used. Windows
/// 8 and later: This flag is supported.
///
///
///
///
/// A pointer to an HTTP_RESPONSE structure that defines the HTTP response.
///
/// A pointer to the HTTP_CACHE_POLICY structure used to cache the response.
/// Windows Server 2003 with SP1 and Windows XP with SP2: This parameter is reserved and must be NULL.
///
///
/// Optional. A pointer to a variable that receives the number, in bytes, sent if the function operates synchronously.
///
/// When making an asynchronous call using pOverlapped, set pBytesSent to NULL. Otherwise, when pOverlapped
/// is set to NULL, pBytesSent must contain a valid memory address and not be set to NULL.
///
///
/// This parameter is reserved and must be NULL.
/// This parameter is reserved and must be zero.
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure; for synchronous calls, set to NULL.
///
/// A synchronous call blocks until all response data specified in the pHttpResponse parameter is sent, whereas an asynchronous
/// call immediately returns ERROR_IO_PENDING and the calling application then uses GetOverlappedResult or I/O completion ports to
/// determine when the operation is completed. For more information about using OVERLAPPED structures for synchronization, see
/// Synchronization and Overlapped Input and Output.
///
///
///
///
/// A pointer to the HTTP_LOG_DATA structure used to log the response. Pass a pointer to the HTTP_LOG_FIELDS_DATA structure and cast it
/// to PHTTP_LOG_DATA.
///
///
/// Be aware that even when logging is enabled on a URL Group, or server session, the response will not be logged unless the application
/// supplies the log fields data structure.
///
/// Windows Server 2003 and Windows XP with SP2: This parameter is reserved and must be NULL.
/// Windows Vista and Windows Server 2008: This parameter is new for Windows Vista, and Windows Server 2008
///
///
/// If the function succeeds, the function returns NO_ERROR.
///
/// If the function is used asynchronously, a return value of ERROR_IO_PENDING indicates that the next request is not yet ready
/// and is retrieved later through normal overlapped I/O completion mechanisms.
///
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters is in an unusable form.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
///
///
/// The HttpSendHttpResponse function is used to create and send a response header, and the HttpSendResponseEntityBody function
/// can be used to send entity-body data as required.
///
///
/// If neither a content-length header nor a transfer-encoding header is included with the response, the application must indicate the
/// end of the response by explicitly closing the connection by using the HTTP_SEND_RESPONSE_DISCONNECT flag.
///
///
/// If an application specifies a "Server:" header in a response, using the HttpHeaderServer identifier in the HTTP_KNOWN_HEADER
/// structure, that specified value is placed as the first part of the header, followed by a space and then "Microsoft-HTTPAPI/1.0". If
/// no server header is specified, HttpSendHttpResponse supplies "Microsoft-HTTPAPI/1.0" as the server header.
///
///
/// Note The HttpSendHttpResponse and HttpSendResponseEntityBody function must not be called simultaneously from different
/// threads on the same RequestId.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpsendhttpresponse HTTPAPI_LINKAGE ULONG HttpSendHttpResponse( [in]
// HANDLE RequestQueueHandle, [in] HTTP_REQUEST_ID RequestId, [in] ULONG Flags, [in] PHTTP_RESPONSE HttpResponse, [in, optional]
// PHTTP_CACHE_POLICY CachePolicy, [out] PULONG BytesSent, [in] PVOID Reserved1, [in] ULONG Reserved2, [in] LPOVERLAPPED Overlapped, [in,
// optional] PHTTP_LOG_DATA LogData );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpSendHttpResponse")]
public static extern Win32Error HttpSendHttpResponse([In] HREQQUEUEv1 RequestQueueHandle, [In] HTTP_REQUEST_ID RequestId, [In] HTTP_SEND_RESPONSE_FLAG Flags,
in HTTP_RESPONSE_V2 HttpResponse, in HTTP_CACHE_POLICY CachePolicy, [Optional] IntPtr BytesSent, [In, Optional] IntPtr Reserved1, [In, Optional] uint Reserved2,
in NativeOverlapped Overlapped, in HTTP_LOG_DATA LogData);
/// The HttpSendHttpResponse function sends an HTTP response to the specified HTTP request.
///
///
/// A handle to the request queue from which the specified request was retrieved. A request queue is created and its handle returned by a
/// call to the HttpCreateRequestQueue function.
///
///
/// Windows Server 2003 with SP1 and Windows XP with SP2: The handle to the request queue is created by the HttpCreateHttpHandle function.
///
///
///
/// An identifier of the HTTP request to which this response corresponds. This value is returned in the RequestId member of the
/// HTTP_REQUEST structure by a call to the HttpReceiveHttpRequest function. This value cannot be HTTP_NULL_ID.
///
///
/// This parameter can be a combination of some of the following flag values. Those that are mutually exclusive are marked accordingly.
///
///
/// Flags
/// Meaning
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_DISCONNECT
///
/// The network connection should be disconnected after sending this response, overriding any persistent connection features associated
/// with the version of HTTP in use.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_MORE_DATA
///
/// Additional entity body data for this response is sent by the application through one or more subsequent calls to
/// HttpSendResponseEntityBody. The last call sending entity-body data then sets this flag to zero.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_BUFFER_DATA
///
/// This flag enables buffering of data in the kernel on a per-response basis. It should be used by an application doing synchronous I/O
/// or by an application doing asynchronous I/O with no more than one outstanding send at a time. Applications that use asynchronous I/O
/// and that may have more than one send outstanding at a time should not use this flag. When this flag is set, it should also be used
/// consistently in calls to the HttpSendResponseEntityBody function. Windows Server 2003: This flag is not supported. This flag
/// is new for Windows Server 2003 with SP1.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_ENABLE_NAGLING
///
/// Enables the TCP nagling algorithm for this send only. Windows Server 2003 with SP1 and Windows XP with SP2: This flag is not supported.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_PROCESS_RANGES
///
/// Specifies that for a range request, the full response content is passed and the caller wants the HTTP API to process ranges
/// appropriately. Windows Server 2008 R2 and Windows 7 or later. Note This flag is supported.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_OPAQUE
///
/// Specifies that the request/response is not HTTP compliant and all subsequent bytes should be treated as entity-body. Applications
/// specify this flag when it is accepting a Web Socket upgrade request and informing HTTP.sys to treat the connection data as opaque
/// data. This flag is only allowed when the StatusCode member of pHttpResponse is 101, switching protocols.
/// HttpSendHttpResponse returns ERROR_INVALID_PARAMETER for all other HTTP response types if this flag is used. Windows
/// 8 and later: This flag is supported.
///
///
///
///
/// A pointer to an HTTP_RESPONSE structure that defines the HTTP response.
///
/// A pointer to the HTTP_CACHE_POLICY structure used to cache the response.
/// Windows Server 2003 with SP1 and Windows XP with SP2: This parameter is reserved and must be NULL.
///
///
/// Optional. A pointer to a variable that receives the number, in bytes, sent if the function operates synchronously.
///
/// When making an asynchronous call using pOverlapped, set pBytesSent to NULL. Otherwise, when pOverlapped
/// is set to NULL, pBytesSent must contain a valid memory address and not be set to NULL.
///
///
/// This parameter is reserved and must be NULL.
/// This parameter is reserved and must be zero.
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure; for synchronous calls, set to NULL.
///
/// A synchronous call blocks until all response data specified in the pHttpResponse parameter is sent, whereas an asynchronous
/// call immediately returns ERROR_IO_PENDING and the calling application then uses GetOverlappedResult or I/O completion ports to
/// determine when the operation is completed. For more information about using OVERLAPPED structures for synchronization, see
/// Synchronization and Overlapped Input and Output.
///
///
///
///
/// A pointer to the HTTP_LOG_DATA structure used to log the response. Pass a pointer to the HTTP_LOG_FIELDS_DATA structure and cast it
/// to PHTTP_LOG_DATA.
///
///
/// Be aware that even when logging is enabled on a URL Group, or server session, the response will not be logged unless the application
/// supplies the log fields data structure.
///
/// Windows Server 2003 and Windows XP with SP2: This parameter is reserved and must be NULL.
/// Windows Vista and Windows Server 2008: This parameter is new for Windows Vista, and Windows Server 2008
///
///
/// If the function succeeds, the function returns NO_ERROR.
///
/// If the function is used asynchronously, a return value of ERROR_IO_PENDING indicates that the next request is not yet ready
/// and is retrieved later through normal overlapped I/O completion mechanisms.
///
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters is in an unusable form.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
///
///
/// The HttpSendHttpResponse function is used to create and send a response header, and the HttpSendResponseEntityBody function
/// can be used to send entity-body data as required.
///
///
/// If neither a content-length header nor a transfer-encoding header is included with the response, the application must indicate the
/// end of the response by explicitly closing the connection by using the HTTP_SEND_RESPONSE_DISCONNECT flag.
///
///
/// If an application specifies a "Server:" header in a response, using the HttpHeaderServer identifier in the HTTP_KNOWN_HEADER
/// structure, that specified value is placed as the first part of the header, followed by a space and then "Microsoft-HTTPAPI/1.0". If
/// no server header is specified, HttpSendHttpResponse supplies "Microsoft-HTTPAPI/1.0" as the server header.
///
///
/// Note The HttpSendHttpResponse and HttpSendResponseEntityBody function must not be called simultaneously from different
/// threads on the same RequestId.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpsendhttpresponse HTTPAPI_LINKAGE ULONG HttpSendHttpResponse( [in]
// HANDLE RequestQueueHandle, [in] HTTP_REQUEST_ID RequestId, [in] ULONG Flags, [in] PHTTP_RESPONSE HttpResponse, [in, optional]
// PHTTP_CACHE_POLICY CachePolicy, [out] PULONG BytesSent, [in] PVOID Reserved1, [in] ULONG Reserved2, [in] LPOVERLAPPED Overlapped, [in,
// optional] PHTTP_LOG_DATA LogData );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpSendHttpResponse")]
public static extern Win32Error HttpSendHttpResponse([In] HREQQUEUEv1 RequestQueueHandle, [In] HTTP_REQUEST_ID RequestId, [In] HTTP_SEND_RESPONSE_FLAG Flags,
in HTTP_RESPONSE_V2 HttpResponse, [In, Optional] IntPtr CachePolicy, out uint BytesSent, [In, Optional] IntPtr Reserved1, [In, Optional] uint Reserved2,
[In, Optional] IntPtr Overlapped, [In, Optional] IntPtr LogData);
/// The HttpSendHttpResponse function sends an HTTP response to the specified HTTP request.
///
///
/// A handle to the request queue from which the specified request was retrieved. A request queue is created and its handle returned by a
/// call to the HttpCreateRequestQueue function.
///
///
/// Windows Server 2003 with SP1 and Windows XP with SP2: The handle to the request queue is created by the HttpCreateHttpHandle function.
///
///
///
/// An identifier of the HTTP request to which this response corresponds. This value is returned in the RequestId member of the
/// HTTP_REQUEST structure by a call to the HttpReceiveHttpRequest function. This value cannot be HTTP_NULL_ID.
///
///
/// This parameter can be a combination of some of the following flag values. Those that are mutually exclusive are marked accordingly.
///
///
/// Flags
/// Meaning
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_DISCONNECT
///
/// The network connection should be disconnected after sending this response, overriding any persistent connection features associated
/// with the version of HTTP in use.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_MORE_DATA
///
/// Additional entity body data for this response is sent by the application through one or more subsequent calls to
/// HttpSendResponseEntityBody. The last call sending entity-body data then sets this flag to zero.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_BUFFER_DATA
///
/// This flag enables buffering of data in the kernel on a per-response basis. It should be used by an application doing synchronous I/O
/// or by an application doing asynchronous I/O with no more than one outstanding send at a time. Applications that use asynchronous I/O
/// and that may have more than one send outstanding at a time should not use this flag. When this flag is set, it should also be used
/// consistently in calls to the HttpSendResponseEntityBody function. Windows Server 2003: This flag is not supported. This flag
/// is new for Windows Server 2003 with SP1.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_ENABLE_NAGLING
///
/// Enables the TCP nagling algorithm for this send only. Windows Server 2003 with SP1 and Windows XP with SP2: This flag is not supported.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_PROCESS_RANGES
///
/// Specifies that for a range request, the full response content is passed and the caller wants the HTTP API to process ranges
/// appropriately. Windows Server 2008 R2 and Windows 7 or later. Note This flag is supported.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_OPAQUE
///
/// Specifies that the request/response is not HTTP compliant and all subsequent bytes should be treated as entity-body. Applications
/// specify this flag when it is accepting a Web Socket upgrade request and informing HTTP.sys to treat the connection data as opaque
/// data. This flag is only allowed when the StatusCode member of pHttpResponse is 101, switching protocols.
/// HttpSendHttpResponse returns ERROR_INVALID_PARAMETER for all other HTTP response types if this flag is used. Windows
/// 8 and later: This flag is supported.
///
///
///
///
/// A pointer to an HTTP_RESPONSE structure that defines the HTTP response.
///
/// A pointer to the HTTP_CACHE_POLICY structure used to cache the response.
/// Windows Server 2003 with SP1 and Windows XP with SP2: This parameter is reserved and must be NULL.
///
///
/// Optional. A pointer to a variable that receives the number, in bytes, sent if the function operates synchronously.
///
/// When making an asynchronous call using pOverlapped, set pBytesSent to NULL. Otherwise, when pOverlapped
/// is set to NULL, pBytesSent must contain a valid memory address and not be set to NULL.
///
///
/// This parameter is reserved and must be NULL.
/// This parameter is reserved and must be zero.
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure; for synchronous calls, set to NULL.
///
/// A synchronous call blocks until all response data specified in the pHttpResponse parameter is sent, whereas an asynchronous
/// call immediately returns ERROR_IO_PENDING and the calling application then uses GetOverlappedResult or I/O completion ports to
/// determine when the operation is completed. For more information about using OVERLAPPED structures for synchronization, see
/// Synchronization and Overlapped Input and Output.
///
///
///
///
/// A pointer to the HTTP_LOG_DATA structure used to log the response. Pass a pointer to the HTTP_LOG_FIELDS_DATA structure and cast it
/// to PHTTP_LOG_DATA.
///
///
/// Be aware that even when logging is enabled on a URL Group, or server session, the response will not be logged unless the application
/// supplies the log fields data structure.
///
/// Windows Server 2003 and Windows XP with SP2: This parameter is reserved and must be NULL.
/// Windows Vista and Windows Server 2008: This parameter is new for Windows Vista, and Windows Server 2008
///
///
/// If the function succeeds, the function returns NO_ERROR.
///
/// If the function is used asynchronously, a return value of ERROR_IO_PENDING indicates that the next request is not yet ready
/// and is retrieved later through normal overlapped I/O completion mechanisms.
///
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters is in an unusable form.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
///
///
/// The HttpSendHttpResponse function is used to create and send a response header, and the HttpSendResponseEntityBody function
/// can be used to send entity-body data as required.
///
///
/// If neither a content-length header nor a transfer-encoding header is included with the response, the application must indicate the
/// end of the response by explicitly closing the connection by using the HTTP_SEND_RESPONSE_DISCONNECT flag.
///
///
/// If an application specifies a "Server:" header in a response, using the HttpHeaderServer identifier in the HTTP_KNOWN_HEADER
/// structure, that specified value is placed as the first part of the header, followed by a space and then "Microsoft-HTTPAPI/1.0". If
/// no server header is specified, HttpSendHttpResponse supplies "Microsoft-HTTPAPI/1.0" as the server header.
///
///
/// Note The HttpSendHttpResponse and HttpSendResponseEntityBody function must not be called simultaneously from different
/// threads on the same RequestId.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpsendhttpresponse HTTPAPI_LINKAGE ULONG HttpSendHttpResponse( [in]
// HANDLE RequestQueueHandle, [in] HTTP_REQUEST_ID RequestId, [in] ULONG Flags, [in] PHTTP_RESPONSE HttpResponse, [in, optional]
// PHTTP_CACHE_POLICY CachePolicy, [out] PULONG BytesSent, [in] PVOID Reserved1, [in] ULONG Reserved2, [in] LPOVERLAPPED Overlapped, [in,
// optional] PHTTP_LOG_DATA LogData );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpSendHttpResponse")]
public static unsafe extern Win32Error HttpSendHttpResponse([In] HREQQUEUEv1 RequestQueueHandle, [In] HTTP_REQUEST_ID RequestId, [In] HTTP_SEND_RESPONSE_FLAG Flags,
[In] IntPtr HttpResponse, [In] HTTP_CACHE_POLICY* CachePolicy, [Optional] uint* BytesSent, [In, Optional] IntPtr Reserved1, [In, Optional] uint Reserved2,
[In, Optional] NativeOverlapped* Overlapped, [In, Optional] HTTP_LOG_DATA* LogData);
/// The HttpSendResponseEntityBody function sends entity-body data associated with an HTTP response.
///
///
/// A handle to the request queue from which the specified request was retrieved. A request queue is created and its handle returned by a
/// call to the HttpCreateRequestQueue function.
///
///
/// Windows Server 2003 with SP1 and Windows XP with SP2: The handle to the request queue is created by the HttpCreateHttpHandle function.
///
///
///
/// An identifier of the HTTP request to which this response corresponds. This value is returned in the RequestId member of the
/// HTTP_REQUEST structure by a call to the HttpReceiveHttpRequest function. It cannot be HTTP_NULL_ID.
///
///
/// A parameter that can include one of the following mutually exclusive flag values.
///
///
/// Flags
/// Meaning
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_DISCONNECT
///
/// The network connection should be disconnected after sending this response, overriding any persistent connection features associated
/// with the version of HTTP in use. Applications should use this flag to indicate the end of the entity in cases where neither content
/// length nor chunked encoding is used.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_MORE_DATA
///
/// Additional entity body data for this response is sent by the application through one or more subsequent calls to
/// HttpSendResponseEntityBody. The last call then sets this flag to zero.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_BUFFER_DATA
///
/// This flag enables buffering of data in the kernel on a per-response basis. It should be used by an application doing synchronous I/O,
/// or by a an application doing asynchronous I/O with no more than one send outstanding at a time. Applications using asynchronous I/O
/// which may have more than one send outstanding at a time should not use this flag. When this flag is set, it should be used
/// consistently in calls to the HttpSendHttpResponse function as well. Windows Server 2003: This flag is not supported. This flag
/// is new for Windows Server 2003 with SP1.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_ENABLE_NAGLING
/// Enables the TCP nagling algorithm for this send only. Windows Vista and later: This flag is not supported.
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_PROCESS_RANGES
///
/// Specifies that for a range request, the full response content is passed and the caller wants the HTTP API to process ranges
/// appropriately. Windows Server 2008 R2 and Windows 7 or later. Note This flag is supported.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_OPAQUE
///
/// Specifies that the request/response is not HTTP compliant and all subsequent bytes should be treated as entity-body. Applications
/// specify this flag when it is accepting a Web Socket upgrade request and informing HTTP.sys to treat the connection data as opaque
/// data. This flag is only allowed when the StatusCode member of pHttpResponse is 101, switching protocols.
/// HttpSendResponseEntityBody returns ERROR_INVALID_PARAMETER for all other HTTP response types if this flag is used.
/// Windows 8 and later: This flag is supported.
///
///
///
/// Caution Combining both flags in a single call to the HttpSendHttpResponse function produces undefined results.
///
///
/// A number of structures in the array pointed to by pEntityChunks. This count cannot exceed 9999.
///
/// A pointer to an array of HTTP_DATA_CHUNK structures to be sent as entity-body data.
///
/// Optional. A pointer to a variable that receives the number, in bytes, sent if the function operates synchronously.
///
/// When making an asynchronous call using pOverlapped, set pBytesSent to NULL. Otherwise, when pOverlapped
/// is set to NULL, pBytesSent must contain a valid memory address, and not be set to NULL.
///
///
/// This parameter is reserved and must be NULL.
/// This parameter is reserved and must be zero.
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure; for synchronous calls, set it to NULL.
///
/// A synchronous call blocks until all response data specified in the pEntityChunks parameter is sent, whereas an asynchronous
/// call immediately returns ERROR_IO_PENDING and the calling application then uses GetOverlappedResult or I/O completion ports to
/// determine when the operation is completed. For more information about using OVERLAPPED structures for synchronization, see
/// Synchronization and Overlapped Input and Output.
///
///
///
///
/// A pointer to the HTTP_LOG_DATA structure used to log the response. Pass a pointer to the HTTP_LOG_FIELDS_DATA structure and cast it
/// to PHTTP_LOG_DATA.
///
///
/// Be aware that even when logging is enabled on a URL Group, or server session, the response will not be logged unless the application
/// supplies the log fields data structure.
///
/// Windows Server 2003 and Windows XP with SP2: This parameter is reserved and must be NULL.
/// Windows Vista and Windows Server 2008: This parameter is new for Windows Vista, and Windows Server 2008
///
///
/// If the function succeeds, the return value is NO_ERROR.
///
/// If the function is used asynchronously, a return value of ERROR_IO_PENDING indicates that the next request is not yet ready
/// and is retrieved later through normal overlapped I/O completion mechanisms.
///
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters is in an unusable form.
///
/// -
/// ERROR_BAD_COMMAND
/// There is a call pending to HttpSendHttpResponse or HttpSendResponseEntityBody having the same RequestId.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
///
///
/// If neither a Content-length header nor a Transfer-encoding header is included in the response headers, the application must indicate
/// the end of the response by explicitly closing the connection using the HTTP_SEND_RESPONSE_DISCONNECT flag.
///
///
/// NoteHttpSendResponseEntityBody (or HttpSendHttpResponse) and HttpSendResponseEntityBody must not be called
/// simultaneously from different threads on the same RequestId.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpsendresponseentitybody HTTPAPI_LINKAGE ULONG
// HttpSendResponseEntityBody( [in] HANDLE RequestQueueHandle, [in] HTTP_REQUEST_ID RequestId, [in] ULONG Flags, [in] USHORT
// EntityChunkCount, [in] PHTTP_DATA_CHUNK EntityChunks, [out] PULONG BytesSent, [in] PVOID Reserved1, [in] ULONG Reserved2, [in]
// LPOVERLAPPED Overlapped, [in, optional] PHTTP_LOG_DATA LogData );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpSendResponseEntityBody")]
public static extern Win32Error HttpSendResponseEntityBody([In] HREQQUEUEv1 RequestQueueHandle, [In] HTTP_REQUEST_ID RequestId, [In] HTTP_SEND_RESPONSE_FLAG Flags,
[In] ushort EntityChunkCount, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] HTTP_DATA_CHUNK[] EntityChunks, [Optional] IntPtr BytesSent,
[In, Optional] IntPtr Reserved1, [In, Optional] uint Reserved2, in NativeOverlapped Overlapped, in HTTP_LOG_DATA LogData);
/// The HttpSendResponseEntityBody function sends entity-body data associated with an HTTP response.
///
///
/// A handle to the request queue from which the specified request was retrieved. A request queue is created and its handle returned by a
/// call to the HttpCreateRequestQueue function.
///
///
/// Windows Server 2003 with SP1 and Windows XP with SP2: The handle to the request queue is created by the HttpCreateHttpHandle function.
///
///
///
/// An identifier of the HTTP request to which this response corresponds. This value is returned in the RequestId member of the
/// HTTP_REQUEST structure by a call to the HttpReceiveHttpRequest function. It cannot be HTTP_NULL_ID.
///
///
/// A parameter that can include one of the following mutually exclusive flag values.
///
///
/// Flags
/// Meaning
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_DISCONNECT
///
/// The network connection should be disconnected after sending this response, overriding any persistent connection features associated
/// with the version of HTTP in use. Applications should use this flag to indicate the end of the entity in cases where neither content
/// length nor chunked encoding is used.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_MORE_DATA
///
/// Additional entity body data for this response is sent by the application through one or more subsequent calls to
/// HttpSendResponseEntityBody. The last call then sets this flag to zero.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_BUFFER_DATA
///
/// This flag enables buffering of data in the kernel on a per-response basis. It should be used by an application doing synchronous I/O,
/// or by a an application doing asynchronous I/O with no more than one send outstanding at a time. Applications using asynchronous I/O
/// which may have more than one send outstanding at a time should not use this flag. When this flag is set, it should be used
/// consistently in calls to the HttpSendHttpResponse function as well. Windows Server 2003: This flag is not supported. This flag
/// is new for Windows Server 2003 with SP1.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_ENABLE_NAGLING
/// Enables the TCP nagling algorithm for this send only. Windows Vista and later: This flag is not supported.
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_PROCESS_RANGES
///
/// Specifies that for a range request, the full response content is passed and the caller wants the HTTP API to process ranges
/// appropriately. Windows Server 2008 R2 and Windows 7 or later. Note This flag is supported.
///
///
/// -
/// HTTP_SEND_RESPONSE_FLAG_OPAQUE
///
/// Specifies that the request/response is not HTTP compliant and all subsequent bytes should be treated as entity-body. Applications
/// specify this flag when it is accepting a Web Socket upgrade request and informing HTTP.sys to treat the connection data as opaque
/// data. This flag is only allowed when the StatusCode member of pHttpResponse is 101, switching protocols.
/// HttpSendResponseEntityBody returns ERROR_INVALID_PARAMETER for all other HTTP response types if this flag is used.
/// Windows 8 and later: This flag is supported.
///
///
///
/// Caution Combining both flags in a single call to the HttpSendHttpResponse function produces undefined results.
///
///
/// A number of structures in the array pointed to by pEntityChunks. This count cannot exceed 9999.
///
/// A pointer to an array of HTTP_DATA_CHUNK structures to be sent as entity-body data.
///
/// Optional. A pointer to a variable that receives the number, in bytes, sent if the function operates synchronously.
///
/// When making an asynchronous call using pOverlapped, set pBytesSent to NULL. Otherwise, when pOverlapped
/// is set to NULL, pBytesSent must contain a valid memory address, and not be set to NULL.
///
///
/// This parameter is reserved and must be NULL.
/// This parameter is reserved and must be zero.
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure; for synchronous calls, set it to NULL.
///
/// A synchronous call blocks until all response data specified in the pEntityChunks parameter is sent, whereas an asynchronous
/// call immediately returns ERROR_IO_PENDING and the calling application then uses GetOverlappedResult or I/O completion ports to
/// determine when the operation is completed. For more information about using OVERLAPPED structures for synchronization, see
/// Synchronization and Overlapped Input and Output.
///
///
///
///
/// A pointer to the HTTP_LOG_DATA structure used to log the response. Pass a pointer to the HTTP_LOG_FIELDS_DATA structure and cast it
/// to PHTTP_LOG_DATA.
///
///
/// Be aware that even when logging is enabled on a URL Group, or server session, the response will not be logged unless the application
/// supplies the log fields data structure.
///
/// Windows Server 2003 and Windows XP with SP2: This parameter is reserved and must be NULL.
/// Windows Vista and Windows Server 2008: This parameter is new for Windows Vista, and Windows Server 2008
///
///
/// If the function succeeds, the return value is NO_ERROR.
///
/// If the function is used asynchronously, a return value of ERROR_IO_PENDING indicates that the next request is not yet ready
/// and is retrieved later through normal overlapped I/O completion mechanisms.
///
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters is in an unusable form.
///
/// -
/// ERROR_BAD_COMMAND
/// There is a call pending to HttpSendHttpResponse or HttpSendResponseEntityBody having the same RequestId.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
///
///
/// If neither a Content-length header nor a Transfer-encoding header is included in the response headers, the application must indicate
/// the end of the response by explicitly closing the connection using the HTTP_SEND_RESPONSE_DISCONNECT flag.
///
///
/// NoteHttpSendResponseEntityBody (or HttpSendHttpResponse) and HttpSendResponseEntityBody must not be called
/// simultaneously from different threads on the same RequestId.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpsendresponseentitybody HTTPAPI_LINKAGE ULONG
// HttpSendResponseEntityBody( [in] HANDLE RequestQueueHandle, [in] HTTP_REQUEST_ID RequestId, [in] ULONG Flags, [in] USHORT
// EntityChunkCount, [in] PHTTP_DATA_CHUNK EntityChunks, [out] PULONG BytesSent, [in] PVOID Reserved1, [in] ULONG Reserved2, [in]
// LPOVERLAPPED Overlapped, [in, optional] PHTTP_LOG_DATA LogData );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpSendResponseEntityBody")]
public static extern Win32Error HttpSendResponseEntityBody([In] HREQQUEUEv1 RequestQueueHandle, [In] HTTP_REQUEST_ID RequestId, [In] HTTP_SEND_RESPONSE_FLAG Flags,
[In] ushort EntityChunkCount, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] HTTP_DATA_CHUNK[] EntityChunks, out uint BytesSent,
[In, Optional] IntPtr Reserved1, [In, Optional] uint Reserved2, [In, Optional] IntPtr Overlapped, [In, Optional] IntPtr LogData);
/// The HttpSetRequestProperty function sets a new property or modifies an existing property on the specified request.
///
/// The handle to the request queue on which the request was received. A request queue is created and its handle returned by a call to
/// the HttpCreateRequestQueue function.
///
///
/// The opaque ID of the request. This ID is located in the RequestId member of the HTTP_REQUEST structure returned by HttpReceiveHttpRequest.
///
///
/// A member of the HTTP_REQUEST_PROPERTY enumeration describing the property type that is set. This must be one of the following:
/// | Property | Meaning | | HttpRequestPropertyStreamError | Sets a stream error on the request. |
///
///
/// A pointer to the buffer that contains the property information.
/// It must point to one of the following property information types based on the property that is set.
///
/// | Property | Configuration Type | | HttpRequestPropertyStreamError | HTTP_REQUEST_PROPERTY_STREAM_ERROR structure |
///
///
/// The length, in bytes, of the buffer pointed to by the Input parameter.
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure; for synchronous calls, set it to NULL.
///
/// A synchronous call blocks until the operation is complete, whereas an asynchronous call immediately returns ERROR_IO_PENDING
/// and the calling application then uses GetOverlappedResult or I/O completion ports to determine when the operation is completed. For
/// more information about using OVERLAPPED structures for synchronization, see Synchronization and Overlapped Input and Output.
///
///
///
/// If the function succeeds, it returns ERROR_SUCCESS.
/// If the function fails, it returns a system error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpsetrequestproperty HTTPAPI_LINKAGE ULONG HttpSetRequestProperty(
// [in] HANDLE RequestQueueHandle, [in] HTTP_OPAQUE_ID Id, [in] HTTP_REQUEST_PROPERTY PropertyId, [in] PVOID Input, [in] ULONG
// InputPropertySize, [in] LPOVERLAPPED Overlapped );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpSetRequestProperty")]
public static extern Win32Error HttpSetRequestProperty([In] HREQQUEUE RequestQueueHandle, [In] HTTP_OPAQUE_ID Id, [In] HTTP_REQUEST_PROPERTY PropertyId,
[In] IntPtr Input, [In] uint InputPropertySize, in NativeOverlapped Overlapped);
/// The HttpSetRequestProperty function sets a new property or modifies an existing property on the specified request.
///
/// The handle to the request queue on which the request was received. A request queue is created and its handle returned by a call to
/// the HttpCreateRequestQueue function.
///
///
/// The opaque ID of the request. This ID is located in the RequestId member of the HTTP_REQUEST structure returned by HttpReceiveHttpRequest.
///
///
/// A member of the HTTP_REQUEST_PROPERTY enumeration describing the property type that is set. This must be one of the following:
/// | Property | Meaning | | HttpRequestPropertyStreamError | Sets a stream error on the request. |
///
///
/// A pointer to the buffer that contains the property information.
/// It must point to one of the following property information types based on the property that is set.
///
/// | Property | Configuration Type | | HttpRequestPropertyStreamError | HTTP_REQUEST_PROPERTY_STREAM_ERROR structure |
///
///
/// The length, in bytes, of the buffer pointed to by the Input parameter.
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure; for synchronous calls, set it to NULL.
///
/// A synchronous call blocks until the operation is complete, whereas an asynchronous call immediately returns ERROR_IO_PENDING
/// and the calling application then uses GetOverlappedResult or I/O completion ports to determine when the operation is completed. For
/// more information about using OVERLAPPED structures for synchronization, see Synchronization and Overlapped Input and Output.
///
///
///
/// If the function succeeds, it returns ERROR_SUCCESS.
/// If the function fails, it returns a system error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpsetrequestproperty HTTPAPI_LINKAGE ULONG HttpSetRequestProperty(
// [in] HANDLE RequestQueueHandle, [in] HTTP_OPAQUE_ID Id, [in] HTTP_REQUEST_PROPERTY PropertyId, [in] PVOID Input, [in] ULONG
// InputPropertySize, [in] LPOVERLAPPED Overlapped );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpSetRequestProperty")]
public static extern Win32Error HttpSetRequestProperty([In] HREQQUEUE RequestQueueHandle, [In] HTTP_OPAQUE_ID Id, [In] HTTP_REQUEST_PROPERTY PropertyId,
[In] IntPtr Input, [In] uint InputPropertySize, [In, Optional] IntPtr Overlapped);
///
/// The HttpSetRequestQueueProperty function sets a new property or modifies an existing property on the request queue identified
/// by the specified handle.
///
///
/// The handle to the request queue on which the property is set. A request queue is created and its handle returned by a call to the
/// HttpCreateRequestQueue function.
///
///
/// A member of the HTTP_SERVER_PROPERTY enumeration describing the property type that is set. This must be one of the following:
///
///
/// Property
/// Meaning
///
/// -
/// HttpServer503VerbosityProperty
/// Modifies or sets the current verbosity level of 503 responses generated for the request queue.
///
/// -
/// HttpServerQueueLengthProperty
/// Modifies or sets the limit on the number of outstanding requests in the request queue.
///
/// -
/// HttpServerStateProperty
/// Modifies or sets the state of the request queue. The state must be either active or inactive.
///
///
///
///
/// A pointer to the buffer that contains the property information.
/// pPropertyInformation
/// points to one of the following property information types based on the property that is set.
///
///
/// Property
/// Configuration Type
///
/// -
/// HttpServerStateProperty
/// HTTP_ENABLED_STATE enumeration
///
/// -
/// HttpServerQueueLengthProperty
/// ULONG
///
/// -
/// HttpServer503VerbosityProperty
/// HTTP_503_RESPONSE_VERBOSITY enumeration
///
///
///
/// The length, in bytes, of the buffer pointed to by the pPropertyInformation parameter.
/// Reserved. Must be zero.
/// Reserved. Must be NULL.
///
/// If the function succeeds, it returns NO_ERROR.
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
///
/// The Reserved parameter is not zero or the pReserved parameter is not NULL. The property type specified in the
/// Property parameter is not supported for request queues. The pPropertyInformation parameter is NULL. The
/// PropertyInformationLength parameter is zero. The application does not have permission to set properties on the request queue.
/// Only the application that created the request queue can set the properties.
///
///
/// -
/// ERROR_NOT_SUPPORTED
///
/// The handle to the request queue is an HTTP version 1.0 handle. Property management is only supported on HTTP version 2.0 or later
/// request queues.
///
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpsetrequestqueueproperty HTTPAPI_LINKAGE ULONG
// HttpSetRequestQueueProperty( [in] HANDLE RequestQueueHandle, [in] HTTP_SERVER_PROPERTY Property, [in] PVOID PropertyInformation, [in]
// ULONG PropertyInformationLength, [in] ULONG Reserved1, [in] PVOID Reserved2 );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpSetRequestQueueProperty")]
public static extern Win32Error HttpSetRequestQueueProperty([In] HREQQUEUE RequestQueueHandle, [In] HTTP_SERVER_PROPERTY Property,
[In] IntPtr PropertyInformation, [In] uint PropertyInformationLength, [In, Optional] uint Reserved1, [In, Optional] IntPtr Reserved2);
///
/// The HttpSetRequestQueueProperty function sets a new property or modifies an existing property on the request queue identified
/// by the specified handle.
///
/// The type of the value being set.
///
/// The handle to the request queue on which the property is set. A request queue is created and its handle returned by a call to the
/// HttpCreateRequestQueue function.
///
///
/// The property information.
/// pPropertyInformation is one of the following property information types.
///
///
/// Property
/// Configuration Type
///
/// -
/// HttpServerStateProperty
/// HTTP_ENABLED_STATE enumeration
///
/// -
/// HttpServerQueueLengthProperty
/// ULONG
///
/// -
/// HttpServer503VerbosityProperty
/// HTTP_503_RESPONSE_VERBOSITY enumeration
///
///
///
///
/// If the function succeeds, it returns NO_ERROR.
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
///
/// The Reserved parameter is not zero or the pReserved parameter is not NULL. The property type specified in the
/// Property parameter is not supported for request queues. The pPropertyInformation parameter is NULL. The
/// PropertyInformationLength parameter is zero. The application does not have permission to set properties on the request queue.
/// Only the application that created the request queue can set the properties.
///
///
/// -
/// ERROR_NOT_SUPPORTED
///
/// The handle to the request queue is an HTTP version 1.0 handle. Property management is only supported on HTTP version 2.0 or later
/// request queues.
///
///
///
///
/// PropertyInformation
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpSetRequestQueueProperty")]
public static Win32Error HttpSetRequestQueueProperty([In] HREQQUEUE RequestQueueHandle, T PropertyInformation) where T : struct
{
if (!CorrespondingTypeAttribute.CanSet(out var Property))
throw new ArgumentOutOfRangeException(nameof(PropertyInformation));
using SafeCoTaskMemStruct mem = new(PropertyInformation);
return HttpSetRequestQueueProperty(RequestQueueHandle, Property, mem, mem.Size);
}
///
/// The HttpSetServerSessionProperty function sets a new server session property or modifies an existing property on the specified
/// server session.
///
/// The server session for which the property is set.
///
/// A member of the HTTP_SERVER_PROPERTY enumeration that describes the property type that is set. This can be one of the following.
///
///
/// Property
/// Meaning
///
/// -
/// HttpServerStateProperty
/// Modifies or sets the state of the server session. The state can be either enabled or disabled; the default state is enabled.
///
/// -
/// HttpServerTimeoutsProperty
/// Modifies or sets the server session connection timeout limits.
///
/// -
/// HttpServerQosProperty
/// Modifies or sets the bandwidth throttling for the server session. By default, the HTTP Server API does not limit bandwidth.
///
/// -
/// HttpServerLoggingProperty
///
/// Enables or disables logging for the server session. This property sets only centralized W3C and centralized binary logging. By
/// default, logging is not enabled.
///
///
/// -
/// HttpServerAuthenticationProperty
/// Enables kernel mode server side authentication for the Basic, NTLM, Negotiate, and Digest authentication schemes.
///
/// -
/// HttpServerExtendedAuthenticationProperty
/// Enables kernel mode server side authentication for the Kerberos authentication scheme.
///
/// -
/// HttpServerChannelBindProperty
/// Enables server side authentication that uses a channel binding token (CBT).
///
///
///
///
/// A pointer to the buffer that contains the property data.
/// pPropertyInformation
/// points to a property data structure, listed in the following table, based on the property that is set.
///
///
/// Property
/// Structure
///
/// -
/// HttpServerStateProperty
/// HTTP_STATE_INFO
///
/// -
/// HttpServerLoggingProperty
/// HTTP_LOGGING_INFO
///
/// -
/// HttpServerQosProperty
/// HTTP_QOS_SETTING_INFO
///
/// -
/// HttpServerTimeoutsProperty
/// HTTP_TIMEOUT_LIMIT_INFO
///
/// -
/// HttpServerAuthenticationProperty
/// HTTP_SERVER_AUTHENTICATION_INFO
///
/// -
/// HttpServerExtendedAuthenticationProperty
/// HTTP_SERVER_AUTHENTICATION_INFO
///
/// -
/// HttpServerChannelBindProperty
/// HTTP_CHANNEL_BIND_INFO
///
///
///
/// The length, in bytes, of the buffer pointed to by the pPropertyInformation parameter.
///
/// If the function succeeds, it returns NO_ERROR
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
///
/// The property type specified in the Property parameter is not supported for server sessions. The pPropertyInformation
/// parameter is NULL. The PropertyInformationLength parameter is zero. The ServerSessionId parameter does not
/// contain a valid server session. The application does not have permission to set the server session properties. Only the application
/// that created the server session can set the properties.
///
///
///
///
///
///
/// Server sessions are top level configuration containers for configuration data that applies to all of the URL groups created under
/// them. The server session is created with HttpCreateServerSession.
///
///
/// The pPropertyInformation parameter points to the configuration structure for the property type that is set. The
/// PropertyInformationLength parameter specifies the size, in bytes, of the configuration structure. For example, when setting
/// the HttpServerTimeoutsProperty the pPropertyInformation parameter must point to a buffer that is at least equal to the
/// size of the HTTP_TIMEOUT_LIMIT_INFO structure.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpsetserversessionproperty HTTPAPI_LINKAGE ULONG
// HttpSetServerSessionProperty( [in] HTTP_SERVER_SESSION_ID ServerSessionId, [in] HTTP_SERVER_PROPERTY Property, [in] PVOID
// PropertyInformation, [in] ULONG PropertyInformationLength );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpSetServerSessionProperty")]
public static extern Win32Error HttpSetServerSessionProperty([In] HTTP_SERVER_SESSION_ID ServerSessionId, [In] HTTP_SERVER_PROPERTY Property,
[In] IntPtr PropertyInformation, [In] uint PropertyInformationLength);
///
/// The HttpSetServerSessionProperty function sets a new server session property or modifies an existing property on the specified
/// server session.
///
/// The type of .
/// The server session for which the property is set.
///
/// The property data.
/// pPropertyInformation is a property data structure, listed in the following table.
///
///
/// Property
/// Structure
///
/// -
/// HttpServerStateProperty
/// HTTP_STATE_INFO
///
/// -
/// HttpServerLoggingProperty
/// HTTP_LOGGING_INFO
///
/// -
/// HttpServerQosProperty
/// HTTP_QOS_SETTING_INFO
///
/// -
/// HttpServerTimeoutsProperty
/// HTTP_TIMEOUT_LIMIT_INFO
///
/// -
/// HttpServerAuthenticationProperty
/// HTTP_SERVER_AUTHENTICATION_INFO
///
/// -
/// HttpServerExtendedAuthenticationProperty
/// HTTP_SERVER_AUTHENTICATION_INFO
///
/// -
/// HttpServerChannelBindProperty
/// HTTP_CHANNEL_BIND_INFO
///
///
///
///
/// If the function succeeds, it returns NO_ERROR
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
///
/// The property type specified in the Property parameter is not supported for server sessions. The pPropertyInformation
/// parameter is NULL. The PropertyInformationLength parameter is zero. The ServerSessionId parameter does not
/// contain a valid server session. The application does not have permission to set the server session properties. Only the application
/// that created the server session can set the properties.
///
///
///
///
/// PropertyInformation
///
///
/// Server sessions are top level configuration containers for configuration data that applies to all of the URL groups created under
/// them. The server session is created with HttpCreateServerSession.
///
///
/// The pPropertyInformation parameter points to the configuration structure for the property type that is set. The
/// PropertyInformationLength parameter specifies the size, in bytes, of the configuration structure. For example, when setting
/// the HttpServerTimeoutsProperty the pPropertyInformation parameter must point to a buffer that is at least equal to the
/// size of the HTTP_TIMEOUT_LIMIT_INFO structure.
///
///
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpSetServerSessionProperty")]
public static Win32Error HttpSetServerSessionProperty([In] HTTP_SERVER_SESSION_ID ServerSessionId, T PropertyInformation) where T : struct
{
if (!CorrespondingTypeAttribute.CanSet(out var Property))
throw new ArgumentOutOfRangeException(nameof(PropertyInformation));
using SafeCoTaskMemStruct mem = new(PropertyInformation);
return HttpSetServerSessionProperty(ServerSessionId, Property, mem, mem.Size);
}
///
/// The HttpSetServiceConfiguration function creates and sets a configuration record for the HTTP Server API configuration store.
/// The call fails if the specified record already exists. To change a given configuration record, delete it and then recreate it with a
/// different value.
///
/// Reserved. Must be zero.
///
/// Type of configuration record to be set. This parameter can be one of the following values from the HTTP_SERVICE_CONFIG_ID enumeration.
///
///
/// ConfigId value
/// Meaning
///
/// -
/// HttpServiceConfigIPListenList
/// Sets a record in the IP Listen List.
///
/// -
/// HttpServiceConfigSSLCertInfo
/// Sets a specified SSL certificate record.
///
/// -
/// HttpServiceConfigUrlAclInfo
/// Sets a URL reservation record.
///
/// -
/// HttpServiceConfigTimeout
/// Sets a specified HTTP Server API wide connection time-out. Windows Vista and later: This enumeration value is supported.
///
/// -
/// HttpServiceConfigSslSniCertInfo
///
/// Sets a specified SSL Server Name Indication (SNI) certificate record. Windows 8 and later: This enumeration value is supported.
///
///
/// -
/// HttpServiceConfigSslCcsCertInfo
///
/// Sets the SSL certificate record that specifies that Http.sys should consult the Centralized Certificate Store (CCS) store to find
/// certificates if the port receives a Transport Layer Security (TLS) handshake. The port is specified by the KeyDesc member of
/// the HTTP_SERVICE_CONFIG_SSL_CCS_SET structure that you pass to the pConfigInformation parameter. Windows 8 and later:
/// This enumeration value is supported.
///
///
///
///
///
/// A pointer to a buffer that contains the appropriate data to specify the type of record to be set.
///
///
/// ConfigId value
/// Meaning
///
/// -
/// HttpServiceConfigIPListenList
/// HTTP_SERVICE_CONFIG_IP_LISTEN_PARAM structure.
///
/// -
/// HttpServiceConfigSSLCertInfo
/// HTTP_SERVICE_CONFIG_SSL_SET structure.
///
/// -
/// HttpServiceConfigUrlAclInfo
/// HTTP_SERVICE_CONFIG_URLACL_SET structure.
///
/// -
/// HttpServiceConfigTimeout
/// HTTP_SERVICE_CONFIG_TIMEOUT_SET structure. Windows Vista and later: This structure is supported.
///
/// -
/// HttpServiceConfigSslSniCertInfo
///
/// HTTP_SERVICE_CONFIG_SSL_SNI_SET structure. The hostname will be "*" when the SSL central certificate store is queried and wildcard
/// bindings are used, and a host name for regular SNI. Windows 8 and later: This structure is supported.
///
///
/// -
/// HttpServiceConfigSslCcsCertInfo
/// HTTP_SERVICE_CONFIG_SSL_CCS_SET structure. Windows 8 and later: This structure is supported.
///
///
///
/// Size, in bytes, of the pConfigInformation buffer.
/// This parameter is reserved and must be NULL.
///
/// If the function succeeds, the return value is NO_ERROR.
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_ALREADY_EXISTS
/// The specified record already exists, and must be deleted in order for its value to be re-set.
///
/// -
/// ERROR_INSUFFICIENT_BUFFER
/// The buffer size specified in the ConfigInformationLength parameter is insufficient.
///
/// -
/// ERROR_INVALID_HANDLE
/// The ServiceHandle parameter is invalid.
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters is in an unusable form.
///
/// -
/// ERROR_NO_SUCH_LOGON_SESSION
/// The SSL Certificate used is invalid. This can occur only if the HttpServiceConfigSSLCertInfo parameter is used.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
///
/// The configuration parameters set with HttpSetServiceConfiguration are applied to all the HTTP Server API applications on the
/// machine, and persist when the HTTP Server API shuts down, or when the computer is restarted.
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpsetserviceconfiguration HTTPAPI_LINKAGE ULONG
// HttpSetServiceConfiguration( [in] HANDLE ServiceHandle, [in] HTTP_SERVICE_CONFIG_ID ConfigId, [in] PVOID pConfigInformation, [in]
// ULONG ConfigInformationLength, [in] LPOVERLAPPED pOverlapped );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpSetServiceConfiguration")]
public static extern Win32Error HttpSetServiceConfiguration([In, Optional] HANDLE ServiceHandle, [In] HTTP_SERVICE_CONFIG_ID ConfigId,
[In] IntPtr pConfigInformation, [In] uint ConfigInformationLength, [In, Optional] IntPtr pOverlapped);
///
/// The HttpSetServiceConfiguration function creates and sets a configuration record for the HTTP Server API configuration store.
/// The call fails if the specified record already exists. To change a given configuration record, delete it and then recreate it with a
/// different value.
///
/// The type of .
///
/// Type of configuration record to be set. This parameter can be one of the following values from the HTTP_SERVICE_CONFIG_ID enumeration.
///
///
/// ConfigId value
/// Meaning
///
/// -
/// HttpServiceConfigIPListenList
/// Sets a record in the IP Listen List.
///
/// -
/// HttpServiceConfigSSLCertInfo
/// Sets a specified SSL certificate record.
///
/// -
/// HttpServiceConfigUrlAclInfo
/// Sets a URL reservation record.
///
/// -
/// HttpServiceConfigTimeout
/// Sets a specified HTTP Server API wide connection time-out. Windows Vista and later: This enumeration value is supported.
///
/// -
/// HttpServiceConfigSslSniCertInfo
///
/// Sets a specified SSL Server Name Indication (SNI) certificate record. Windows 8 and later: This enumeration value is supported.
///
///
/// -
/// HttpServiceConfigSslCcsCertInfo
///
/// Sets the SSL certificate record that specifies that Http.sys should consult the Centralized Certificate Store (CCS) store to find
/// certificates if the port receives a Transport Layer Security (TLS) handshake. The port is specified by the KeyDesc member of
/// the HTTP_SERVICE_CONFIG_SSL_CCS_SET structure that you pass to the pConfigInformation parameter. Windows 8 and later:
/// This enumeration value is supported.
///
///
///
///
///
/// The appropriate data to specify the type of record to be set.
///
///
/// ConfigId value
/// Meaning
///
/// -
/// HttpServiceConfigIPListenList
/// HTTP_SERVICE_CONFIG_IP_LISTEN_PARAM structure.
///
/// -
/// HttpServiceConfigSSLCertInfo
/// HTTP_SERVICE_CONFIG_SSL_SET structure.
///
/// -
/// HttpServiceConfigUrlAclInfo
/// HTTP_SERVICE_CONFIG_URLACL_SET structure.
///
/// -
/// HttpServiceConfigTimeout
/// HTTP_SERVICE_CONFIG_TIMEOUT_SET structure. Windows Vista and later: This structure is supported.
///
/// -
/// HttpServiceConfigSslSniCertInfo
///
/// HTTP_SERVICE_CONFIG_SSL_SNI_SET structure. The hostname will be "*" when the SSL central certificate store is queried and wildcard
/// bindings are used, and a host name for regular SNI. Windows 8 and later: This structure is supported.
///
///
/// -
/// HttpServiceConfigSslCcsCertInfo
/// HTTP_SERVICE_CONFIG_SSL_CCS_SET structure. Windows 8 and later: This structure is supported.
///
///
///
///
/// If the function succeeds, the return value is NO_ERROR.
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_ALREADY_EXISTS
/// The specified record already exists, and must be deleted in order for its value to be re-set.
///
/// -
/// ERROR_INSUFFICIENT_BUFFER
/// The buffer size specified in the ConfigInformationLength parameter is insufficient.
///
/// -
/// ERROR_INVALID_HANDLE
/// The ServiceHandle parameter is invalid.
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters is in an unusable form.
///
/// -
/// ERROR_NO_SUCH_LOGON_SESSION
/// The SSL Certificate used is invalid. This can occur only if the HttpServiceConfigSSLCertInfo parameter is used.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
///
/// The configuration parameters set with HttpSetServiceConfiguration are applied to all the HTTP Server API applications on the
/// machine, and persist when the HTTP Server API shuts down, or when the computer is restarted.
///
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpSetServiceConfiguration")]
public static Win32Error HttpSetServiceConfiguration([In] HTTP_SERVICE_CONFIG_ID ConfigId, in T pConfigInformation) where T:struct
{
using var mem = new SafeCoTaskMemStruct(pConfigInformation);
return HttpSetServiceConfiguration(default, ConfigId, mem, mem.Size, default);
}
///
/// The HttpSetServiceConfiguration function creates and sets a configuration record for the HTTP Server API configuration store.
/// The call fails if the specified record already exists. To change a given configuration record, delete it and then recreate it with a
/// different value.
///
/// The type of .
///
/// The appropriate data to specify the type of record to be set.
///
///
/// ConfigId value
/// Meaning
///
/// -
/// HttpServiceConfigIPListenList
/// HTTP_SERVICE_CONFIG_IP_LISTEN_PARAM structure.
///
/// -
/// HttpServiceConfigSSLCertInfo
/// HTTP_SERVICE_CONFIG_SSL_SET structure.
///
/// -
/// HttpServiceConfigUrlAclInfo
/// HTTP_SERVICE_CONFIG_URLACL_SET structure.
///
/// -
/// HttpServiceConfigTimeout
/// HTTP_SERVICE_CONFIG_TIMEOUT_SET structure. Windows Vista and later: This structure is supported.
///
/// -
/// HttpServiceConfigSslSniCertInfo
///
/// HTTP_SERVICE_CONFIG_SSL_SNI_SET structure. The hostname will be "*" when the SSL central certificate store is queried and wildcard
/// bindings are used, and a host name for regular SNI. Windows 8 and later: This structure is supported.
///
///
/// -
/// HttpServiceConfigSslCcsCertInfo
/// HTTP_SERVICE_CONFIG_SSL_CCS_SET structure. Windows 8 and later: This structure is supported.
///
///
///
///
/// If the function succeeds, the return value is NO_ERROR.
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_ALREADY_EXISTS
/// The specified record already exists, and must be deleted in order for its value to be re-set.
///
/// -
/// ERROR_INSUFFICIENT_BUFFER
/// The buffer size specified in the ConfigInformationLength parameter is insufficient.
///
/// -
/// ERROR_INVALID_HANDLE
/// The ServiceHandle parameter is invalid.
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters is in an unusable form.
///
/// -
/// ERROR_NO_SUCH_LOGON_SESSION
/// The SSL Certificate used is invalid. This can occur only if the HttpServiceConfigSSLCertInfo parameter is used.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
/// pConfigInformation
///
/// The configuration parameters set with HttpSetServiceConfiguration are applied to all the HTTP Server API applications on the
/// machine, and persist when the HTTP Server API shuts down, or when the computer is restarted.
///
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpSetServiceConfiguration")]
public static Win32Error HttpSetServiceConfiguration(in T pConfigInformation) where T : struct
{
if (!CorrespondingTypeAttribute.CanSet(out var ConfigId))
throw new ArgumentOutOfRangeException(nameof(pConfigInformation));
using var mem = new SafeCoTaskMemStruct(pConfigInformation);
return HttpSetServiceConfiguration(default, ConfigId, mem, mem.Size, default);
}
///
/// The HttpSetUrlGroupProperty function sets a new property or modifies an existing property on the specified URL Group.
///
/// The ID of the URL Group for which the property is set.
///
///
/// A member of the HTTP_SERVER_PROPERTY enumeration that describes the property type that is modified or set. This can be one of the following:
///
///
///
/// Property
/// Meaning
///
/// -
/// HttpServerAuthenticationProperty
/// Enables server-side authentication for the URL Group using the Basic, NTLM, Negotiate, and Digest authentication schemes.
///
/// -
/// HttpServerExtendedAuthenticationProperty
/// Enables server-side authentication for the URL Group using the Kerberos authentication scheme.
///
/// -
/// HttpServerQosProperty
///
/// This value maps to the generic HTTP_QOS_SETTING_INFO structure with QosType set to either HttpQosSettingTypeBandwidth
/// or HttpQosSettingTypeConnectionLimit. If HttpQosSettingTypeBandwidth, modifies or sets the bandwidth throttling for the
/// URL Group. If HttpQosSettingTypeConnectionLimit, modifies or sets the maximum number of outstanding connections served for a
/// URL Group at any time.
///
///
/// -
/// HttpServerBindingProperty
/// Modifies or sets the URL Group association with a request queue.
///
/// -
/// HttpServerLoggingProperty
/// Modifies or sets logging for the URL Group.
///
/// -
/// HttpServerStateProperty
/// Modifies or sets the state of the URL Group. The state can be either enabled or disabled.
///
/// -
/// HttpServerTimeoutsProperty
/// Modifies or sets the connection timeout limits for the URL Group.
///
/// -
/// HttpServerChannelBindProperty
/// Enables server side authentication that uses a channel binding token (CBT).
///
///
///
///
/// A pointer to the buffer that contains the property information.
/// pPropertyInformation
/// points to one of the following property information structures based on the property that is set.
///
///
/// Property
/// Structure
///
/// -
/// HttpServerAuthenticatonProperty
/// HTTP_SERVER_AUTHENTICATION_INFO
///
/// -
/// HttpServerExtendedAuthenticationProperty
/// HTTP_SERVER_AUTHENTICATION_INFO
///
/// -
/// HttpServerQosProperty
/// HTTP_QOS_SETTING_INFO
///
/// -
/// HttpServerBindingProperty
/// HTTP_BINDING_INFO
///
/// -
/// HttpServerLoggingProperty
/// HTTP_LOGGING_INFO
///
/// -
/// HttpServerStateProperty
/// HTTP_STATE_INFO
///
/// -
/// HttpServerTimeoutsProperty
/// HTTP_TIMEOUT_LIMIT_INFO
///
/// -
/// HttpServerChannelBindProperty
/// HTTP_CHANNEL_BIND_INFO
///
///
///
/// The length, in bytes, of the buffer pointed to by the pPropertyInformation parameter.
///
/// If the function succeeds, it returns NO_ERROR.
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
///
/// The property type specified in the Property parameter is not supported for URL Groups. The pPropertyInformation
/// parameter is NULL. The PropertyInformationLength parameter is zero. The UrlGroupId parameter does not contain a
/// valid server session. The application does not have permission to set the URL Group properties. Only the application that created the
/// URL Group can set the properties.
///
///
///
///
///
/// After the URL Group is created it must be associated with a request queue to receive requests. To associate the URL Group with a
/// request queue, the application calls HttpSetUrlGroupProperty with the HttpServerBindingProperty property. If this
/// property is not set, matching requests for the URL Group are not delivered to a request queue and the HTTP Server API generates a 503 response.
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpseturlgroupproperty HTTPAPI_LINKAGE ULONG HttpSetUrlGroupProperty(
// [in] HTTP_URL_GROUP_ID UrlGroupId, [in] HTTP_SERVER_PROPERTY Property, [in] PVOID PropertyInformation, [in] ULONG
// PropertyInformationLength );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpSetUrlGroupProperty")]
public static extern Win32Error HttpSetUrlGroupProperty([In] HTTP_URL_GROUP_ID UrlGroupId, [In] HTTP_SERVER_PROPERTY Property,
[In] IntPtr PropertyInformation, [In] uint PropertyInformationLength);
///
/// The HttpSetUrlGroupProperty function sets a new property or modifies an existing property on the specified URL Group.
///
/// The type of .
/// The ID of the URL Group for which the property is set.
///
/// The property information.
/// pPropertyInformation is one of the following property information structures based on the property that is set.
///
///
/// Property
/// Structure
///
/// -
/// HttpServerAuthenticatonProperty
/// HTTP_SERVER_AUTHENTICATION_INFO
///
/// -
/// HttpServerExtendedAuthenticationProperty
/// HTTP_SERVER_AUTHENTICATION_INFO
///
/// -
/// HttpServerQosProperty
/// HTTP_QOS_SETTING_INFO
///
/// -
/// HttpServerBindingProperty
/// HTTP_BINDING_INFO
///
/// -
/// HttpServerLoggingProperty
/// HTTP_LOGGING_INFO
///
/// -
/// HttpServerStateProperty
/// HTTP_STATE_INFO
///
/// -
/// HttpServerTimeoutsProperty
/// HTTP_TIMEOUT_LIMIT_INFO
///
/// -
/// HttpServerChannelBindProperty
/// HTTP_CHANNEL_BIND_INFO
///
///
///
///
/// If the function succeeds, it returns NO_ERROR.
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
///
/// The property type specified in the Property parameter is not supported for URL Groups. The pPropertyInformation
/// parameter is NULL. The PropertyInformationLength parameter is zero. The UrlGroupId parameter does not contain a
/// valid server session. The application does not have permission to set the URL Group properties. Only the application that created the
/// URL Group can set the properties.
///
///
///
///
///
/// After the URL Group is created it must be associated with a request queue to receive requests. To associate the URL Group with a
/// request queue, the application calls HttpSetUrlGroupProperty with the HttpServerBindingProperty property. If this
/// property is not set, matching requests for the URL Group are not delivered to a request queue and the HTTP Server API generates a 503 response.
///
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpSetUrlGroupProperty")]
public static Win32Error HttpSetUrlGroupProperty([In] HTTP_URL_GROUP_ID UrlGroupId, in T PropertyInformation) where T: struct
{
if (!CorrespondingTypeAttribute.CanSet(out var Property))
throw new ArgumentOutOfRangeException(nameof(PropertyInformation));
using SafeCoTaskMemStruct mem = new(PropertyInformation);
return HttpSetUrlGroupProperty(UrlGroupId, Property, mem, mem.Size);
}
///
/// The HttpShutdownRequestQueue function stops queuing requests for the specified request queue process. Outstanding calls to
/// HttpReceiveHttpRequest are canceled.
///
///
/// The handle to the request queue that is shut down. A request queue is created and its handle returned by a call to the
/// HttpCreateRequestQueue function.
///
///
/// If the function succeeds, it returns NO_ERROR
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
///
/// The ReqQueueHandle parameter does not contain a valid request queue. The application does not have permission to shut down the
/// request queue.
///
///
///
///
///
///
/// HttpShutdownRequestQueue cancels outstanding requests and stops all processing on the request queue process. The following
/// steps are performed when this function is called:
///
///
/// -
/// The request queue process is marked for cleanup and no new requests are routed to the request queue process.
///
/// -
/// If the calling process is a controller, outstanding HttpWaitForDemandStart calls are canceled.
///
/// -
/// Pending HttpReceiveHttpRequest calls from the calling process are canceled.
///
/// -
/// Requests that are already bound to the calling process are canceled.
///
/// -
///
/// The unreceived pending requests that are queued to the request queue process rerouted to another request queue process. If no other
/// request queue process is available, the pending requests are saved until the request queue is closed, or another non-controller
/// request queue process launches.
///
///
/// -
/// Pending HttpWaitForDisconnect calls initiated by the calling process are canceled.
///
/// -
/// Outstanding responses indicated by the calling process are not affected, they are properly completed.
///
///
///
/// Be aware that if the request queue handle is shared by multiple processes, HttpShutdownRequestQueue limits cleanup to the
/// calling process. Other processes currently working on the request queue are not affected.
///
///
/// HttpShutdownRequestQueue can be used by applications to recycle request queue processes. For this purpose,
/// HttpShutdownRequestQueue is called prior to terminating a process that shares the request queue with other processes. After
/// HttpShutdownRequestQueue returns, the process can be safely terminated or recycled.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpshutdownrequestqueue HTTPAPI_LINKAGE ULONG
// HttpShutdownRequestQueue( [in] HANDLE RequestQueueHandle );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpShutdownRequestQueue")]
public static extern Win32Error HttpShutdownRequestQueue([In] HREQQUEUE RequestQueueHandle);
///
/// The HttpTerminate function cleans up resources used by the HTTP Server API to process calls by an application. An application
/// should call HttpTerminate once for every time it called HttpInitialize, with matching flag settings.
///
///
/// Termination options. This parameter can be one or more of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// HTTP_INITIALIZE_CONFIG
/// Release all resources used by applications that modify the HTTP configuration.
///
/// -
/// HTTP_INITIALIZE_SERVER
/// Release all resources used by server applications.
///
///
///
/// This parameter is reserved and must be NULL.
///
/// If the function succeeds, the return value is NO_ERROR.
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters is in an unusable form.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
///
/// Every call to HttpInitialize should be matched by a corresponding call to HttpTerminate. For example, if you call
/// HttpInitialize with HTTP_INITIALIZE_SERVER, you must call HttpTerminate with HTTP_INITIALIZE_SERVER. If you call
/// HttpInitialize twice, once with HTTP_INITIALIZE_SERVER and the second time with HTTP_INITIALIZE_CONFIG, you can call
/// HttpTerminate one time with both flags.
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpterminate HTTPAPI_LINKAGE ULONG HttpTerminate( [in] ULONG Flags,
// [in, out] PVOID pReserved );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpTerminate")]
public static extern Win32Error HttpTerminate(HTTP_INIT Flags, IntPtr pReserved = default);
///
/// Updates atomically a service configuration parameter that specifies a Transport Layer Security (TLS) certificate in a configuration
/// record within the HTTP Server API configuration store.
///
/// Reserved and must be NULL.
///
///
/// The type of configuration record to update. This parameter can be one of the following values from the HTTP_SERVICE_CONFIG_ID enumeration.
///
///
///
/// ConfigId value
/// Meaning
///
/// -
/// HttpServiceConfigSSLCertInfo
/// Updates a specified SSL certificate record.
///
/// -
/// HttpServiceConfigSslSniCertInfo
/// Updates a specified SSL Server Name Indication (SNI) certificate record.
///
/// -
/// HttpServiceConfigSslCcsCertInfo
///
/// Updates the SSL certificate record that specifies that Http.sys should consult the Centralized Certificate Store (CCS) store to find
/// certificates if the port receives a TLS handshake. The port is specified by the KeyDesc member of the
/// HTTP_SERVICE_CONFIG_SSL_CCS_SET structure that you pass to the pConfigInfo parameter.
///
///
///
///
///
///
/// A pointer to a buffer that contains the appropriate data to specify the type of record to update. The following table shows the type
/// of data the buffer contains for the different possible values of the ConfigId parameter.
///
///
///
/// ConfigId value
/// Type of data in the pConfigInfo buffer
///
/// -
/// HttpServiceConfigSSLCertInfo
/// HTTP_SERVICE_CONFIG_SSL_SET structure.
///
/// -
/// HttpServiceConfigSslSniCertInfo
///
/// HTTP_SERVICE_CONFIG_SSL_SNI_SET structure. The hostname will be "*" when the SSL central certificate store is queried and wildcard
/// bindings are used, and a host name for regular SNI.
///
///
/// -
/// HttpServiceConfigSslCcsCertInfo
///
/// HTTP_SERVICE_CONFIG_SSL_CCS_SET structure. This structure is used to add the CCS store on the specified port, as well as to delete,
/// retrieve, or update an existing SSL CCS record.
///
///
///
///
/// The size, in bytes, of the ConfigInfo buffer.
/// Reserved and must be NULL.
///
/// If the function succeeds, the return value is ERROR_SUCCESS.
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_FILE_NOT_FOUND
/// The specified record does not exist.
///
/// -
/// ERROR_INSUFFICIENT_BUFFER
/// The buffer size specified in the ConfigInfoLength parameter is insufficient.
///
/// -
/// ERROR_INVALID_HANDLE
/// The ServiceHandle parameter is invalid.
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters is in an unusable form.
///
/// -
/// ERROR_NO_SUCH_LOGON_SESSION
/// The SSL Certificate used is invalid. This can occur only if the HttpServiceConfigSSLCertInfo parameter is used.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
///
/// The configuration parameters that you update with HttpUpdateServiceConfiguration are applied to all the HTTP Server API
/// applications on the machine, and persist when the HTTP Server API shuts down, or when the computer is restarted.
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpupdateserviceconfiguration HTTPAPI_LINKAGE ULONG
// HttpUpdateServiceConfiguration( [in] HANDLE Handle, [in] HTTP_SERVICE_CONFIG_ID ConfigId, [in] PVOID ConfigInfo, [in] ULONG
// ConfigInfoLength, [in] LPOVERLAPPED Overlapped );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpUpdateServiceConfiguration")]
public static extern Win32Error HttpUpdateServiceConfiguration([In, Optional] HANDLE Handle, [In] HTTP_SERVICE_CONFIG_ID ConfigId,
[In] IntPtr ConfigInfo, [In] uint ConfigInfoLength, [In, Optional] IntPtr Overlapped);
///
/// The HttpWaitForDemandStart function waits for the arrival of a new request that can be served by a new request queue process.
///
///
/// A handle to the request queue on which demand start is registered. A request queue is created and its handle returned by a call to
/// the HttpCreateRequestQueue function.
///
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure; for synchronous calls, set it to NULL.
///
/// A synchronous call blocks until a request has arrived in the specified queue, whereas an asynchronous call immediately returns
/// ERROR_IO_PENDING and the calling application then uses GetOverlappedResult or I/O completion ports to determine when the
/// operation is completed. For more information about using OVERLAPPED structures for synchronization, see Synchronization and
/// Overlapped Input and Output.
///
///
///
/// If the function succeeds, it returns NO_ERROR.
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// The ReqQueueHandle parameter does not contain a valid request queue.
///
/// -
/// ERROR_INVALID_ID_AUTHORITY
/// The calling process is not the controller process for this request queue.
///
/// -
/// ERROR_INVALID_HANDLE
/// The calling process has already initiated a shutdown on the request queue or has closed the request queue handle.
///
/// -
/// ERROR_ALREADY_EXISTS
/// A demand start registration already exists for the request queue.
///
///
///
///
///
/// Only the controller process can call HttpWaitForDemandStart to register a demand start notification. The controller process is
/// the process that created the request queue and indicated that it is a controller process by passing the
/// HTTP_CREATE_REQUEST_QUEUE_FLAG_CONTROLLER flag. If a process other than the controlling process calls
/// HttpWaitForDemandStart, the HTTP Server API returns ERROR_INVALID_ID_AUTHORITY.
///
///
/// HttpWaitForDemandStart completes when a new request arrives for the specified request queue. At this time, a controller
/// process can use this API to start a new worker process to server pending requests. Delayed start of the worker process allows
/// applications to avoid consuming resources until they are required.
///
///
/// The HTTP Server API allows only one outstanding notification registered on a request queue at any time. The HTTP Server API does not
/// enforce limitations on the number of times that HttpWaitForDemandStart can be called on the same request queue consecutively.
/// There is no limit on the number of outstanding processes that are working on the same request queue.
///
///
/// The HTTP Server API supports canceling asynchronous HttpWaitForDemandStart calls. Applications can use CancelIoEx with the
/// overlapped structure supplied in the pOverlapped parameter, to cancel an outstanding HttpWaitForDemandStart call.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpwaitfordemandstart HTTPAPI_LINKAGE ULONG HttpWaitForDemandStart(
// [in] HANDLE RequestQueueHandle, [in, optional] LPOVERLAPPED Overlapped );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpWaitForDemandStart")]
public static extern Win32Error HttpWaitForDemandStart([In] HREQQUEUE RequestQueueHandle, in NativeOverlapped Overlapped);
///
/// The HttpWaitForDemandStart function waits for the arrival of a new request that can be served by a new request queue process.
///
///
/// A handle to the request queue on which demand start is registered. A request queue is created and its handle returned by a call to
/// the HttpCreateRequestQueue function.
///
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure; for synchronous calls, set it to NULL.
///
/// A synchronous call blocks until a request has arrived in the specified queue, whereas an asynchronous call immediately returns
/// ERROR_IO_PENDING and the calling application then uses GetOverlappedResult or I/O completion ports to determine when the
/// operation is completed. For more information about using OVERLAPPED structures for synchronization, see Synchronization and
/// Overlapped Input and Output.
///
///
///
/// If the function succeeds, it returns NO_ERROR.
/// If the function fails, it returns one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// The ReqQueueHandle parameter does not contain a valid request queue.
///
/// -
/// ERROR_INVALID_ID_AUTHORITY
/// The calling process is not the controller process for this request queue.
///
/// -
/// ERROR_INVALID_HANDLE
/// The calling process has already initiated a shutdown on the request queue or has closed the request queue handle.
///
/// -
/// ERROR_ALREADY_EXISTS
/// A demand start registration already exists for the request queue.
///
///
///
///
///
/// Only the controller process can call HttpWaitForDemandStart to register a demand start notification. The controller process is
/// the process that created the request queue and indicated that it is a controller process by passing the
/// HTTP_CREATE_REQUEST_QUEUE_FLAG_CONTROLLER flag. If a process other than the controlling process calls
/// HttpWaitForDemandStart, the HTTP Server API returns ERROR_INVALID_ID_AUTHORITY.
///
///
/// HttpWaitForDemandStart completes when a new request arrives for the specified request queue. At this time, a controller
/// process can use this API to start a new worker process to server pending requests. Delayed start of the worker process allows
/// applications to avoid consuming resources until they are required.
///
///
/// The HTTP Server API allows only one outstanding notification registered on a request queue at any time. The HTTP Server API does not
/// enforce limitations on the number of times that HttpWaitForDemandStart can be called on the same request queue consecutively.
/// There is no limit on the number of outstanding processes that are working on the same request queue.
///
///
/// The HTTP Server API supports canceling asynchronous HttpWaitForDemandStart calls. Applications can use CancelIoEx with the
/// overlapped structure supplied in the pOverlapped parameter, to cancel an outstanding HttpWaitForDemandStart call.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpwaitfordemandstart HTTPAPI_LINKAGE ULONG HttpWaitForDemandStart(
// [in] HANDLE RequestQueueHandle, [in, optional] LPOVERLAPPED Overlapped );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpWaitForDemandStart")]
public static extern Win32Error HttpWaitForDemandStart([In] HREQQUEUE RequestQueueHandle, [In, Optional] IntPtr Overlapped);
///
/// The HttpWaitForDisconnect function notifies the application when the connection to an HTTP client is broken for any reason.
///
///
///
/// A handle to the request queue that handles requests from the specified connection. A request queue is created and its handle returned
/// by a call to the HttpCreateRequestQueue function.
///
///
/// Windows Server 2003 with SP1 and Windows XP with SP2: The handle to the request queue is created by the HttpCreateHttpHandle function.
///
///
///
/// Identifier for the connection to the client computer. This value is returned in the ConnectionID member of the HTTP_REQUEST
/// structure by a call to the HttpReceiveHttpRequest function.
///
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure; for synchronous calls, set it to NULL.
///
/// A synchronous call blocks until the connection is broken, whereas an asynchronous call immediately returns ERROR_IO_PENDING and the
/// calling application then uses GetOverlappedResult or I/O completion ports to determine when the operation is completed. For
/// information about using OVERLAPPED structures for synchronization, see Synchronization and Overlapped Input and Output.
///
///
///
/// If the function succeeds, the return value is NO_ERROR.
///
/// If the function is used asynchronously, a return value of ERROR_IO_PENDING indicates that the next request is not yet ready and is
/// retrieved later through normal overlapped I/O completion mechanisms.
///
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters is in an unusable form.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpwaitfordisconnect HTTPAPI_LINKAGE ULONG HttpWaitForDisconnect(
// [in] HANDLE RequestQueueHandle, [in] HTTP_CONNECTION_ID ConnectionId, [in] LPOVERLAPPED Overlapped );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpWaitForDisconnect")]
public static extern Win32Error HttpWaitForDisconnect([In] HREQQUEUEv1 RequestQueueHandle, [In] HTTP_CONNECTION_ID ConnectionId, in NativeOverlapped Overlapped);
///
/// The HttpWaitForDisconnect function notifies the application when the connection to an HTTP client is broken for any reason.
///
///
///
/// A handle to the request queue that handles requests from the specified connection. A request queue is created and its handle returned
/// by a call to the HttpCreateRequestQueue function.
///
///
/// Windows Server 2003 with SP1 and Windows XP with SP2: The handle to the request queue is created by the HttpCreateHttpHandle function.
///
///
///
/// Identifier for the connection to the client computer. This value is returned in the ConnectionID member of the HTTP_REQUEST
/// structure by a call to the HttpReceiveHttpRequest function.
///
///
/// For asynchronous calls, set pOverlapped to point to an OVERLAPPED structure; for synchronous calls, set it to NULL.
///
/// A synchronous call blocks until the connection is broken, whereas an asynchronous call immediately returns ERROR_IO_PENDING and the
/// calling application then uses GetOverlappedResult or I/O completion ports to determine when the operation is completed. For
/// information about using OVERLAPPED structures for synchronization, see Synchronization and Overlapped Input and Output.
///
///
///
/// If the function succeeds, the return value is NO_ERROR.
///
/// If the function is used asynchronously, a return value of ERROR_IO_PENDING indicates that the next request is not yet ready and is
/// retrieved later through normal overlapped I/O completion mechanisms.
///
/// If the function fails, the return value is one of the following error codes.
///
///
/// Value
/// Meaning
///
/// -
/// ERROR_INVALID_PARAMETER
/// One or more of the supplied parameters is in an unusable form.
///
/// -
/// Other
/// A system error code defined in WinError.h.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpwaitfordisconnect HTTPAPI_LINKAGE ULONG HttpWaitForDisconnect(
// [in] HANDLE RequestQueueHandle, [in] HTTP_CONNECTION_ID ConnectionId, [in] LPOVERLAPPED Overlapped );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpWaitForDisconnect")]
public static extern Win32Error HttpWaitForDisconnect([In] HREQQUEUEv1 RequestQueueHandle, [In] HTTP_CONNECTION_ID ConnectionId, [In, Optional] IntPtr Overlapped);
/// This function is an extension to HttpWaitForDisconnect.
///
///
///
///
/// None
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpwaitfordisconnectex HTTPAPI_LINKAGE ULONG HttpWaitForDisconnectEx(
// [in] HANDLE RequestQueueHandle, [in] HTTP_CONNECTION_ID ConnectionId, ULONG Reserved, [in] LPOVERLAPPED Overlapped );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpWaitForDisconnectEx")]
public static extern Win32Error HttpWaitForDisconnectEx([In] HREQQUEUEv1 RequestQueueHandle, [In] HTTP_CONNECTION_ID ConnectionId, [In, Optional] uint Reserved, [In, Optional] IntPtr Overlapped);
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
private static extern Win32Error HttpCreateServerSession(HTTPAPI_VERSION Version, out HTTP_SERVER_SESSION_ID ServerSessionId, uint Reserved = 0);
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
private static extern Win32Error HttpCreateUrlGroup(HTTP_SERVER_SESSION_ID ServerSessionId, out HTTP_URL_GROUP_ID pUrlGroupId, uint Reserved = 0);
///
/// The HttpPrepareUrl function parses, analyzes, and normalizes a non-normalized Unicode or punycode URL so it is safe and valid
/// to use in other HTTP functions.
///
/// Reserved. Must be NULL.
/// Reserved. Must be zero.
/// A pointer to a string that represents the non-normalized Unicode or punycode URL to prepare.
///
/// On successful output, a pointer to a string that represents the normalized URL.
/// Note Free PreparedUrl using HeapFree.
///
///
/// If the function succeeds, it returns ERROR_SUCCESS.
/// If the function fails, it returns one of the following or a system error code defined in WinError.h.
///
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpprepareurl HTTPAPI_LINKAGE ULONG HttpPrepareUrl( PVOID Reserved,
// ULONG Flags, [in] PCWSTR Url, [out] PWSTR *PreparedUrl );
[DllImport(Lib_Httpapi, SetLastError = false, ExactSpelling = true)]
[PInvokeData("http.h", MSDNShortId = "NF:http.HttpPrepareUrl")]
private static extern Win32Error HttpPrepareUrl([In, Optional] IntPtr Reserved, [Optional] uint Flags, [MarshalAs(UnmanagedType.LPWStr)] string Url,
out SafeHeapBlock PreparedUrl);
/// Provides a handle to a v2 HTTP Request Queue.
[StructLayout(LayoutKind.Sequential)]
public struct HREQQUEUE : IHandle
{
private readonly IntPtr handle;
/// Initializes a new instance of the struct.
/// An object that represents the pre-existing handle to use.
public HREQQUEUE(IntPtr preexistingHandle) => handle = preexistingHandle;
/// Returns an invalid handle by instantiating a object with .
public static HREQQUEUE NULL { get; } = default;
/// Gets a value indicating whether this instance is a null handle.
public bool IsNull => handle == IntPtr.Zero;
/// Implements the operator !.
/// The handle.
/// The result of the operator.
public static bool operator !(HREQQUEUE h1) => h1.IsNull;
/// Performs an explicit conversion from to .
/// The handle.
/// The result of the conversion.
public static explicit operator IntPtr(HREQQUEUE h) => h.handle;
/// Performs an implicit conversion from to .
/// The pointer to a handle.
/// The result of the conversion.
public static implicit operator HREQQUEUE(IntPtr h) => new(h);
/// Performs an implicit conversion from to .
/// The pointer to a handle.
/// The result of the conversion.
public static implicit operator HREQQUEUEv1(HREQQUEUE h) => h.handle;
/// Implements the operator !=.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator !=(HREQQUEUE h1, HREQQUEUE h2) => h1.handle != h2.handle;
/// Implements the operator ==.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator ==(HREQQUEUE h1, HREQQUEUE h2) => h1.handle == h2.handle;
///
public override bool Equals(object? obj) => (obj is IHandle h && handle == h.DangerousGetHandle()) || (obj is IntPtr p && handle == p);
///
public override int GetHashCode() => handle.GetHashCode();
///
public IntPtr DangerousGetHandle() => handle;
}
/// Provides a handle to an HTTP request queue.
[StructLayout(LayoutKind.Sequential)]
public struct HREQQUEUEv1 : IHandle
{
private readonly IntPtr handle;
/// Initializes a new instance of the struct.
/// An object that represents the pre-existing handle to use.
public HREQQUEUEv1(IntPtr preexistingHandle) => handle = preexistingHandle;
/// Returns an invalid handle by instantiating a object with .
public static HREQQUEUEv1 NULL { get; } = default;
/// Gets a value indicating whether this instance is a null handle.
public bool IsNull => handle == IntPtr.Zero;
/// Performs an explicit conversion from to .
/// The handle.
/// The result of the conversion.
public static explicit operator IntPtr(HREQQUEUEv1 h) => h.handle;
/// Performs an implicit conversion from to .
/// The pointer to a handle.
/// The result of the conversion.
public static implicit operator HREQQUEUEv1(IntPtr h) => new(h);
/// Implements the operator !.
/// The handle.
/// The result of the operator.
public static bool operator !(HREQQUEUEv1 h1) => h1.IsNull;
/// Implements the operator !=.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator !=(HREQQUEUEv1 h1, HREQQUEUEv1 h2) => h1.handle != h2.handle;
/// Implements the operator ==.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator ==(HREQQUEUEv1 h1, HREQQUEUEv1 h2) => h1.handle == h2.handle;
///
public override bool Equals(object? obj) => (obj is IHandle h && handle == h.DangerousGetHandle()) || (obj is IntPtr p && handle == p);
///
public override int GetHashCode() => handle.GetHashCode();
///
public IntPtr DangerousGetHandle() => handle;
}
/// Provides a for that is disposed using .
public class SafeHREQQUEUE : SafeHANDLE
{
/// Initializes a new instance of the class and assigns an existing handle.
/// An object that represents the pre-existing handle to use.
///
/// to reliably release the handle during the finalization phase; otherwise, (not recommended).
///
public SafeHREQQUEUE(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
/// Initializes a new instance of the class.
private SafeHREQQUEUE() : base() { }
/// Performs an implicit conversion from to .
/// The safe handle instance.
/// The result of the conversion.
public static implicit operator HREQQUEUE(SafeHREQQUEUE h) => h.handle;
/// Performs an implicit conversion from to .
/// The safe handle instance.
/// The result of the conversion.
public static implicit operator HREQQUEUEv1(SafeHREQQUEUE h) => h.handle;
///
protected override bool InternalReleaseHandle() => HttpCloseRequestQueue(handle).Succeeded;
}
/// Provides a for that is disposed using .
public class SafeHREQQUEUEv1 : SafeHANDLE, IKernelHandle
{
/// Initializes a new instance of the class and assigns an existing handle.
/// An object that represents the pre-existing handle to use.
///
/// to reliably release the handle during the finalization phase; otherwise, (not recommended).
///
public SafeHREQQUEUEv1(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
/// Initializes a new instance of the class.
private SafeHREQQUEUEv1() : base() { }
/// Performs an implicit conversion from to .
/// The safe handle instance.
/// The result of the conversion.
public static implicit operator HREQQUEUEv1(SafeHREQQUEUEv1 h) => h.handle;
///
protected override bool InternalReleaseHandle() => CloseHandle(handle);
}
/// Provides a for that is disposed using .
[StructLayout(LayoutKind.Sequential)]
public class SafeHTTP_SERVER_SESSION_ID : IDisposable
{
private ulong id;
private SafeHTTP_SERVER_SESSION_ID() { }
/// Initializes a new instance of the class.
/// The identifier.
internal SafeHTTP_SERVER_SESSION_ID(ulong id) : base() => this.id = id;
/// Performs an implicit conversion from to .
/// The safe handle instance.
/// The result of the conversion.
public static implicit operator HTTP_SERVER_SESSION_ID(SafeHTTP_SERVER_SESSION_ID h) => h.id;
///
public void Dispose() { HttpCloseServerSession(id).ThrowIfFailed(); id = 0; }
}
/// Provides a for that is disposed using .
[StructLayout(LayoutKind.Sequential)]
public class SafeHTTP_URL_GROUP_ID : IDisposable
{
private ulong id;
private SafeHTTP_URL_GROUP_ID() : base() { }
/// Initializes a new instance of the class.
/// The identifier.
internal SafeHTTP_URL_GROUP_ID(ulong id) : base() => this.id = id;
/// Performs an implicit conversion from to .
/// The safe handle instance.
/// The result of the conversion.
public static implicit operator HTTP_URL_GROUP_ID(SafeHTTP_URL_GROUP_ID h) => h.id;
///
public void Dispose()
{ HttpCloseUrlGroup(id).ThrowIfFailed(); id = 0; }
}
/// Auto-closing class used to initialize and terminate an HTTP server sesssion.
///
public class SafeHttpInitialize : IDisposable
{
private readonly HTTP_INIT flags;
/// Initializes a new instance of the class.
///
/// HTTP version. This parameter is an HTTPAPI_VERSION structure. For the current version, declare an instance of the structure and
/// set it to the pre-defined value HTTPAPI_VERSION_1 before passing it to HttpInitialize.
///
///
/// Initialization options, which can include one or both of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// HTTP_INITIALIZE_CONFIG
///
/// Perform initialization for applications that use the HTTP configuration functions, HttpSetServiceConfiguration,
/// HttpQueryServiceConfiguration, HttpDeleteServiceConfiguration, and HttpIsFeatureSupported.
///
///
/// -
/// HTTP_INITIALIZE_SERVER
/// Perform initialization for applications that use the HTTP Server API.
///
///
///
public SafeHttpInitialize(HTTPAPI_VERSION Version, HTTP_INIT Flags) => HttpInitialize(Version, flags = Flags).ThrowIfFailed();
/// Initializes a new instance of the class with the latest version.
///
/// Initialization options, which can include one or both of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// HTTP_INITIALIZE_CONFIG
///
/// Perform initialization for applications that use the HTTP configuration functions, HttpSetServiceConfiguration,
/// HttpQueryServiceConfiguration, HttpDeleteServiceConfiguration, and HttpIsFeatureSupported.
///
///
/// -
/// HTTP_INITIALIZE_SERVER
/// Perform initialization for applications that use the HTTP Server API.
///
///
///
public SafeHttpInitialize(HTTP_INIT Flags = HTTP_INIT.HTTP_INITIALIZE_SERVER) : this(HTTPAPI_VERSION.HTTPAPI_VERSION_2, Flags) { }
/// Calls to close the session on disposal.
public void Dispose() => HttpTerminate(flags).ThrowIfFailed();
}
}