summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/noPassthrough/configExpand_rest_noexpand.js2
-rw-r--r--jstests/noPassthrough/configExpand_rest_timeout.js2
-rw-r--r--jstests/noPassthrough/configExpand_rest_wholeconfig.js4
-rw-r--r--jstests/noPassthrough/libs/configExpand/lib.js2
-rw-r--r--jstests/noPassthrough/libs/configExpand/rest_server.py3
-rw-r--r--src/mongo/util/net/http_client_winhttp.cpp14
6 files changed, 18 insertions, 9 deletions
diff --git a/jstests/noPassthrough/configExpand_rest_noexpand.js b/jstests/noPassthrough/configExpand_rest_noexpand.js
index c5e529bc291..d80f4c33ae6 100644
--- a/jstests/noPassthrough/configExpand_rest_noexpand.js
+++ b/jstests/noPassthrough/configExpand_rest_noexpand.js
@@ -29,7 +29,7 @@
// Expansion enabled, but not recursively.
configExpandFailure({
- __rest: web.getURL() + '/reflect/yaml?json=' + encodeURI(JSON.stringify(sicReflect)),
+ __rest: web.getURL() + '/reflect/yaml?yaml=' + encodeURI(jsToYaml(sicReflect)),
type: 'yaml'
},
/__rest support has not been enabled/);
diff --git a/jstests/noPassthrough/configExpand_rest_timeout.js b/jstests/noPassthrough/configExpand_rest_timeout.js
index 5cc03b0ad99..532ce4e6283 100644
--- a/jstests/noPassthrough/configExpand_rest_timeout.js
+++ b/jstests/noPassthrough/configExpand_rest_timeout.js
@@ -22,7 +22,7 @@
scramIterationCount: {__rest: web.getStringReflectionURL('12345', {sleep: 40})},
}
},
- /Timeout was reached/); // Note: This error will be different on windows.
+ /Timeout was reached/);
// Sleep 10 seconds during request, with custom 5 second timeout.
configExpandFailure({
diff --git a/jstests/noPassthrough/configExpand_rest_wholeconfig.js b/jstests/noPassthrough/configExpand_rest_wholeconfig.js
index 8dae413e61e..9be592e5eff 100644
--- a/jstests/noPassthrough/configExpand_rest_wholeconfig.js
+++ b/jstests/noPassthrough/configExpand_rest_wholeconfig.js
@@ -9,9 +9,9 @@
const web = new ConfigExpandRestServer();
web.start();
- const jsonConfig = JSON.stringify({setParameter: {scramIterationCount: 12345}});
+ const yamlConfig = jsToYaml({setParameter: {scramIterationCount: 12345}});
configExpandSuccess(
- {__rest: web.getURL() + '/reflect/yaml?json=' + encodeURI(jsonConfig), type: 'yaml'},
+ {__rest: web.getURL() + '/reflect/yaml?yaml=' + encodeURI(yamlConfig), type: 'yaml'},
function(admin) {
const response =
assert.commandWorked(admin.runCommand({getParameter: 1, scramIterationCount: 1}));
diff --git a/jstests/noPassthrough/libs/configExpand/lib.js b/jstests/noPassthrough/libs/configExpand/lib.js
index 8566f58d70b..856d67f4305 100644
--- a/jstests/noPassthrough/libs/configExpand/lib.js
+++ b/jstests/noPassthrough/libs/configExpand/lib.js
@@ -112,7 +112,7 @@ function jsToYaml(config, toplevel = true) {
}
}
} else if (typeof config === 'string') {
- return "'" + config.replace('\\', '\\\\').replace("'", "\\'") + "'";
+ return "'" + config.replace(/'/g, "''") + "'";
} else {
// Simple scalar JSON types are close enough to YAML types.
return JSON.stringify(config);
diff --git a/jstests/noPassthrough/libs/configExpand/rest_server.py b/jstests/noPassthrough/libs/configExpand/rest_server.py
index 0a6e811b665..9672eaf6341 100644
--- a/jstests/noPassthrough/libs/configExpand/rest_server.py
+++ b/jstests/noPassthrough/libs/configExpand/rest_server.py
@@ -7,7 +7,6 @@ import json
import logging
import time
import urllib.parse
-import yaml
class ConfigExpandRestHandler(http.server.BaseHTTPRequestHandler):
"""
@@ -39,7 +38,7 @@ class ConfigExpandRestHandler(http.server.BaseHTTPRequestHandler):
self.send_response(code)
self.send_header('content-type', 'text/yaml')
self.end_headers()
- self.wfile.write(yaml.dump(json.loads(query['json'][0]), default_flow_style=False).encode())
+ self.wfile.write(query['yaml'][0].encode())
return
self.send_response(http.HTTPStatus.NOT_FOUND)
diff --git a/src/mongo/util/net/http_client_winhttp.cpp b/src/mongo/util/net/http_client_winhttp.cpp
index 227c86bffef..cdae871784e 100644
--- a/src/mongo/util/net/http_client_winhttp.cpp
+++ b/src/mongo/util/net/http_client_winhttp.cpp
@@ -241,8 +241,18 @@ private:
"Failed sending HTTP request",
WinHttpSendRequest(request, _headers.c_str(), -1L, data, data_len, data_len, 0));
- uassertWithErrno("Failed receiving response from server",
- WinHttpReceiveResponse(request, nullptr));
+ if (!WinHttpReceiveResponse(request, nullptr)) {
+ // Carve out timeout which doesn't translate well.
+ const auto err = GetLastError();
+ if (err == ERROR_WINHTTP_TIMEOUT) {
+ uasserted(ErrorCodes::OperationFailed, "Timeout was reached");
+ }
+ const auto msg = errnoWithDescription(err);
+ uasserted(ErrorCodes::OperationFailed,
+ str::stream() << "Failed receiving response from server"
+ << ": "
+ << msg);
+ }
DWORD statusCode = 0;
DWORD statusCodeLength = sizeof(statusCode);