mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 01:21:03 +01:00
SERVER-34228 Make HTTP handling check status code
This commit is contained in:
parent
930e6de854
commit
720d7a3db3
@ -104,6 +104,7 @@ class FreeMonHandler(http.server.BaseHTTPRequestHandler):
|
||||
self.send_response(http.HTTPStatus.INTERNAL_SERVER_ERROR)
|
||||
self.send_header("content-type", "application/octet-stream")
|
||||
self.end_headers()
|
||||
self.wfile.write("Internal Error of some sort.".encode())
|
||||
return
|
||||
|
||||
if fault_type == FAULT_INVALID_REGISTER:
|
||||
|
@ -210,6 +210,22 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
long statusCode;
|
||||
result = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &statusCode);
|
||||
if (result != CURLE_OK) {
|
||||
shared_promise.setError({ErrorCodes::OperationFailed,
|
||||
str::stream() << "Unexpected error retrieving response: "
|
||||
<< curl_easy_strerror(result)});
|
||||
return;
|
||||
}
|
||||
|
||||
if (statusCode != 200) {
|
||||
shared_promise.setError(Status(
|
||||
ErrorCodes::OperationFailed,
|
||||
str::stream() << "Unexpected http status code from server: " << statusCode));
|
||||
return;
|
||||
}
|
||||
|
||||
auto d = dataBuilder.getCursor();
|
||||
shared_promise.emplaceValue(std::vector<uint8_t>(d.data(), d.data() + d.length()));
|
||||
} catch (...) {
|
||||
|
@ -257,6 +257,26 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
DWORD statusCode = 0;
|
||||
DWORD statusCodeLength = sizeof(statusCode);
|
||||
|
||||
if (!WinHttpQueryHeaders(request,
|
||||
WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER,
|
||||
WINHTTP_HEADER_NAME_BY_INDEX,
|
||||
&statusCode,
|
||||
&statusCodeLength,
|
||||
WINHTTP_NO_HEADER_INDEX)) {
|
||||
setError("Error querying status from server");
|
||||
return;
|
||||
}
|
||||
|
||||
if (statusCode != 200) {
|
||||
shared_promise.setError(
|
||||
Status(ErrorCodes::OperationFailed,
|
||||
str::stream() << "Unexpected http status code from server: " << statusCode));
|
||||
return;
|
||||
}
|
||||
|
||||
// Marshal response into vector.
|
||||
std::vector<uint8_t> ret;
|
||||
auto sz = ret.size();
|
||||
|
Loading…
Reference in New Issue
Block a user