diff options
| author | Per Larsson <[email protected]> | 2021-09-28 15:09:15 +0200 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2021-09-28 15:09:15 +0200 |
| commit | 141317786f9d59e95da8316ce40cf30e4dfd7b53 (patch) | |
| tree | 3c863384c6ca68a30e82989994408c5f40159273 /zenhttp/httpsys.cpp | |
| parent | Removed using the bucket name to detect binary cache records and store conten... (diff) | |
| parent | apply: Re-enabled environment variable setup for child processes (diff) | |
| download | zen-141317786f9d59e95da8316ce40cf30e4dfd7b53.tar.xz zen-141317786f9d59e95da8316ce40cf30e4dfd7b53.zip | |
Merge branch 'main' of https://github.com/EpicGames/zen
Diffstat (limited to 'zenhttp/httpsys.cpp')
| -rw-r--r-- | zenhttp/httpsys.cpp | 60 |
1 files changed, 38 insertions, 22 deletions
diff --git a/zenhttp/httpsys.cpp b/zenhttp/httpsys.cpp index 2a50388e3..bccff24ab 100644 --- a/zenhttp/httpsys.cpp +++ b/zenhttp/httpsys.cpp @@ -42,7 +42,7 @@ UTF8_to_wstring(const char* in) if (((*in & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) { - if (sizeof(wchar_t) > 2) + if constexpr (sizeof(wchar_t) > 2) { out.append(1, static_cast<wchar_t>(codepoint)); } @@ -417,7 +417,7 @@ HttpMessageResponseRequest::HandleCompletion(ULONG IoResult, ULONG_PTR NumberOfB if (IoResult != NO_ERROR) { - ZEN_WARN("response aborted due to error: '{}'", GetWindowsErrorAsString(IoResult)); + ZEN_WARN("response aborted due to error: '{}'", GetSystemErrorAsString(IoResult)); // if one transmit failed there's really no need to go on return nullptr; @@ -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,24 +562,30 @@ 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); ZEN_ERROR("failed to send HTTP response (error: '{}'), request URL: '{}', request id: {}", - GetWindowsErrorAsString(SendResult), + GetSystemErrorAsString(SendResult), HttpReq->pRawUrl, HttpReq->RequestId); - ErrorCode = MakeWin32ErrorCode(SendResult); - } - else - { - ErrorCode = {}; + ErrorCode = MakeErrorCode(SendResult); } } @@ -1244,21 +1267,14 @@ InitialRequestHandler::IssueRequest(std::error_code& ErrorCode) { CancelThreadpoolIo(Iocp); - if (HttpApiResult == ERROR_MORE_DATA) - { - // ProcessReceiveAndPostResponse(pIoRequest, pServerContext->Io, ERROR_MORE_DATA); - } - - // CleanupHttpIoRequest(pIoRequest); - - ErrorCode = MakeWin32ErrorCode(HttpApiResult); + ErrorCode = MakeErrorCode(HttpApiResult); ZEN_ERROR("HttpReceiveHttpRequest failed, error {}", ErrorCode.message()); return; } - ErrorCode = std::error_code(); + ErrorCode.clear(); } HttpSysRequestHandler* |