Skip to content

Commit

Permalink
Follow-up to previous commit: Calculate header value.toLower() once
Browse files Browse the repository at this point in the history
Just save the value.toLower() and use it, rather than taking it twice
(as was the case in the previous commit).
  • Loading branch information
cculianu committed Jul 27, 2020
1 parent 27ebc15 commit 00c959e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/RPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,14 +733,17 @@ namespace RPC {
}
sm->gotLength = true;
TraceM("Content length: ", sm->contentLength);
} else if (name == s_connection && value.toLower() != s_keep_alive /* tolerate Connection: keep-alive */) {
static const auto MakeErrMsg = [](const QString & value) {
return QString("Unsupported \"Connection: %1\" header field in response").arg(value);
};
if (value.toLower() == s_close && sm->status == 200)
Warning() << MakeErrMsg(value);
else
DebugM(MakeErrMsg(value));
} else if (name == s_connection) {
// we tolerate "Connection: keep-alive", for everything else warn or print a debug message
if (const auto lowerVal = value.toLower(); lowerVal != s_keep_alive) {
static const auto MakeErrMsg = [](const QString & value) {
return QString("Unsupported \"Connection: %1\" header field in response").arg(value);
};
if (lowerVal == s_close && sm->status == 200)
Warning() << MakeErrMsg(value);
else
DebugM(MakeErrMsg(value));
}
}
} else {
// caught EMPTY line -- this signifies end of header
Expand Down

0 comments on commit 00c959e

Please sign in to comment.