Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge #2050 #1951 #2112 to 0.7 #2126

Merged
merged 3 commits into from
Apr 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions source/vibe/db/mongo/collection.d
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ struct MongoCollection {
foreach (string key, value; bopt)
cmd[key] = value;
auto ret = database.runCommand(cmd);
enforce(ret["ok"].get!double != 0, "findAndModifyExt failed.");
enforce(ret["ok"].get!double != 0, "findAndModifyExt failed: "~ret["errmsg"].opt!string);
return ret["value"];
}

Expand Down Expand Up @@ -276,7 +276,7 @@ struct MongoCollection {
cmd.count = m_name;
cmd.query = query;
auto reply = database.runCommand(cmd);
enforce(reply["ok"].opt!double == 1 || reply["ok"].opt!int == 1, "Count command failed.");
enforce(reply["ok"].opt!double == 1 || reply["ok"].opt!int == 1, "Count command failed: "~reply["errmsg"].opt!string);
switch (reply["n"].type) with (Bson.Type) {
default: assert(false, "Unsupported data type in BSON reply for COUNT");
case double_: return cast(ulong)reply["n"].get!double; // v2.x
Expand Down Expand Up @@ -318,7 +318,7 @@ struct MongoCollection {
cmd.pipeline = pipeline[0];
else cmd.pipeline.args = pipeline;
auto ret = database.runCommand(cmd);
enforce(ret["ok"].get!double == 1, "Aggregate command failed.");
enforce(ret["ok"].get!double == 1, "Aggregate command failed: "~ret["errmsg"].opt!string);
return ret["result"];
}

Expand Down Expand Up @@ -466,7 +466,7 @@ struct MongoCollection {
cmd.dropIndexes = m_name;
cmd.index = name;
auto reply = database.runCommand(cmd);
enforce(reply["ok"].get!double == 1, "dropIndex command failed.");
enforce(reply["ok"].get!double == 1, "dropIndex command failed: "~reply["errmsg"].opt!string);
}

void drop() {
Expand All @@ -477,7 +477,7 @@ struct MongoCollection {
CMD cmd;
cmd.drop = m_name;
auto reply = database.runCommand(cmd);
enforce(reply["ok"].get!double == 1, "drop command failed.");
enforce(reply["ok"].get!double == 1, "drop command failed: "~reply["errmsg"].opt!string);
}
}

Expand Down
10 changes: 8 additions & 2 deletions source/vibe/http/client.d
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,6 @@ final class HTTPClient {
req.headers["User-Agent"] = m_userAgent;
if (m_settings.proxyURL.host !is null){
req.headers["Proxy-Connection"] = "keep-alive";
*close_conn = false; // req.headers.get("Proxy-Connection", "keep-alive") != "keep-alive";
if (confirmed_proxy_auth)
{
import std.base64;
Expand All @@ -628,11 +627,18 @@ final class HTTPClient {
}
else {
req.headers["Connection"] = "keep-alive";
*close_conn = false; // req.headers.get("Connection", "keep-alive") != "keep-alive";
}
req.headers["Accept-Encoding"] = "gzip, deflate";
req.headers["Host"] = m_server;
requester(req);

if (req.httpVersion == HTTPVersion.HTTP_1_0)
*close_conn = true;
else if (m_settings.proxyURL.host !is null)
*close_conn = req.headers.get("Proxy-Connection", "keep-alive") != "keep-alive";
else
*close_conn = req.headers.get("Connection", "keep-alive") != "keep-alive";

req.finalize();

return req.method != HTTPMethod.HEAD;
Expand Down
2 changes: 1 addition & 1 deletion source/vibe/inet/urltransfer.d
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void download(HTTPClient_ = void*)(URL url, scope void delegate(scope InputStrea
static if (is(HTTPClient_ == HTTPClient)) client = client_;
if (!client) client = new HTTPClient();
scope (exit) {
if (client_ !is null)
if (client_ is null) // disconnect default client
client.disconnect();
}

Expand Down