mirror of
https://github.com/apple/foundationdb.git
synced 2025-06-01 10:45:56 +08:00
For HTTP requests, a missing request ID in the response is ignored if the response code is 5xx indicating a server error.
This commit is contained in:
parent
003cc6be18
commit
7ac62fb40f
@ -392,17 +392,17 @@ namespace HTTP {
|
||||
responseID = iid->second;
|
||||
}
|
||||
event.detail("RequestIDReceived", responseID);
|
||||
if(requestID != responseID) {
|
||||
|
||||
// If the response code is 5xx (server error) then a response ID is not expected
|
||||
// so a missing id will be ignored but a mismatching id will still be an error.
|
||||
bool serverError = r->code >= 500 && r->code < 600;
|
||||
|
||||
// If request/response IDs do not match and either this is not a server error
|
||||
// or it is but the response ID is not empty then log an error.
|
||||
if(requestID != responseID && (!serverError || !responseID.empty()) ) {
|
||||
err = http_bad_request_id();
|
||||
|
||||
// Log a non-debug a error
|
||||
Severity sev = SevError;
|
||||
// If the response code is 5xx (server error) and the responseID is empty then just warn
|
||||
if(responseID.empty() && r->code >= 500 && r->code < 600) {
|
||||
sev = SevWarnAlways;
|
||||
}
|
||||
|
||||
TraceEvent(sev, "HTTPRequestFailedIDMismatch")
|
||||
TraceEvent(SevError, "HTTPRequestFailedIDMismatch")
|
||||
.detail("DebugID", conn->getDebugID())
|
||||
.detail("RemoteAddress", conn->getPeerAddress())
|
||||
.detail("Verb", verb)
|
||||
@ -433,6 +433,7 @@ namespace HTTP {
|
||||
return r;
|
||||
} catch(Error &e) {
|
||||
double elapsed = timer() - send_start;
|
||||
// A bad_request_id error would have already been logged in verbose mode before err is thrown above.
|
||||
if(CLIENT_KNOBS->HTTP_VERBOSE_LEVEL > 0 && e.code() != error_code_http_bad_request_id) {
|
||||
printf("[%s] HTTP *ERROR*=%s early=%d, time=%fs %s %s contentLen=%d [%d out]\n",
|
||||
conn->getDebugID().toString().c_str(), e.name(), earlyResponse, elapsed, verb.c_str(), resource.c_str(), contentLen, total_sent);
|
||||
|
Loading…
x
Reference in New Issue
Block a user