diff options
| author | Stefan Boberg <[email protected]> | 2021-09-27 16:24:13 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-09-27 16:24:13 +0200 |
| commit | 250c1ce9c9df36b05dcacb8b10c6330ce8bad4cb (patch) | |
| tree | f22bf86cf56020a3a6020971e2c1537c252d50da /zenhttp/httpsys.cpp | |
| parent | CompactBinary: PLATFORM_SUPPORTS_UNALIGNED_LOADS -> ZEN_PLATFORM_SUPPORTS_UNA... (diff) | |
| download | zen-250c1ce9c9df36b05dcacb8b10c6330ce8bad4cb.tar.xz zen-250c1ce9c9df36b05dcacb8b10c6330ce8bad4cb.zip | |
httpsys: Added HTTP_SEND_RESPONSE_FLAG_BUFFER_DATA to response calls which should improve overall performance (yet to be confirmed)
Also added custom Server: header
Diffstat (limited to 'zenhttp/httpsys.cpp')
| -rw-r--r-- | zenhttp/httpsys.cpp | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/zenhttp/httpsys.cpp b/zenhttp/httpsys.cpp index 747e48bb3..f87d3c21d 100644 --- a/zenhttp/httpsys.cpp +++ b/zenhttp/httpsys.cpp @@ -465,7 +465,7 @@ HttpMessageResponseRequest::IssueRequest(std::error_code& ErrorCode) HttpSendHttpResponse function as well. */ - ULONG SendFlags = 0; + ULONG SendFlags = HTTP_SEND_RESPONSE_FLAG_BUFFER_DATA; if (m_RemainingChunkCount) { @@ -484,6 +484,23 @@ HttpMessageResponseRequest::IssueRequest(std::error_code& ErrorCode) HttpResponse.EntityChunkCount = USHORT(ThisRequestChunkCount); HttpResponse.pEntityChunks = m_HttpDataChunks.data() + ThisRequestChunkOffset; + // Server header + // + // By default this will also add a suffix " Microsoft-HTTPAPI/2.0" to this header + // + // This is controlled via a registry key 'DisableServerHeader', at: + // + // Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP\Parameters + // + // Set DisableServerHeader to 1 to disable suffix, or 2 to disable the header altogether + // + // (reference https://docs.microsoft.com/en-us/archive/blogs/dsnotes/wswcf-remove-server-header) + // + + PHTTP_KNOWN_HEADER ServerHeader = &HttpResponse.Headers.KnownHeaders[HttpHeaderServer]; + ServerHeader->pRawValue = "Zen"; + ServerHeader->RawValueLength = (USHORT)3; + // Content-length header char ContentLengthString[32]; @@ -545,11 +562,21 @@ HttpMessageResponseRequest::IssueRequest(std::error_code& ErrorCode) ); } - if ((SendResult != NO_ERROR) // Synchronous completion, but the completion event will still be posted to IOCP - && (SendResult != ERROR_IO_PENDING) // Asynchronous completion - ) + if (SendResult == NO_ERROR) + { + // Synchronous completion, but the completion event will still be posted to IOCP + + ErrorCode.clear(); + } + else if (SendResult == ERROR_IO_PENDING) + { + // Asynchronous completion, a completion notification will be posted to IOCP + + ErrorCode.clear(); + } + else { - // Some error occurred, no completion will be posted + // An error occurred, no completion will be posted to IOCP CancelThreadpoolIo(Iocp); @@ -560,10 +587,6 @@ HttpMessageResponseRequest::IssueRequest(std::error_code& ErrorCode) ErrorCode = MakeErrorCode(SendResult); } - else - { - ErrorCode = {}; - } } /** @@ -1244,13 +1267,6 @@ InitialRequestHandler::IssueRequest(std::error_code& ErrorCode) { CancelThreadpoolIo(Iocp); - if (HttpApiResult == ERROR_MORE_DATA) - { - // ProcessReceiveAndPostResponse(pIoRequest, pServerContext->Io, ERROR_MORE_DATA); - } - - // CleanupHttpIoRequest(pIoRequest); - ErrorCode = MakeErrorCode(HttpApiResult); ZEN_ERROR("HttpReceiveHttpRequest failed, error {}", ErrorCode.message()); @@ -1258,7 +1274,7 @@ InitialRequestHandler::IssueRequest(std::error_code& ErrorCode) return; } - ErrorCode = std::error_code(); + ErrorCode.clear(); } HttpSysRequestHandler* |