1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-12 10:04:14 +02:00

Allow case-insensitive matching of HTTP connection header values.

The specification allows values for the connection header to be case-insensitive. See https://www.rfc-editor.org/rfc/rfc7230#section-6.1.
This commit is contained in:
David Steele 2022-02-25 10:51:40 -06:00 committed by GitHub
parent 6320712323
commit b33cabe08c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 4 deletions

View File

@ -33,6 +33,19 @@
<p>Retry errors in S3 batch file delete.</p> <p>Retry errors in S3 batch file delete.</p>
</release-item> </release-item>
<release-item>
<github-issue id="1638"/>
<github-pull-request id="1675"/>
<release-item-contributor-list>
<release-item-ideator id="remi.vidier"/>
<release-item-contributor id="david.steele"/>
<release-item-reviewer id="reid.thompson"/>
</release-item-contributor-list>
<p>Allow case-insensitive matching of <proper>HTTP</proper> <id>connection</id> header values.</p>
</release-item>
</release-bug-list> </release-bug-list>
<release-feature-list> <release-feature-list>
@ -11310,6 +11323,11 @@
<contributor-id type="github">Rakshitha-BR</contributor-id> <contributor-id type="github">Rakshitha-BR</contributor-id>
</contributor> </contributor>
<contributor id="remi.vidier">
<contributor-name-display>R&amp;eacute;mi Vidier</contributor-name-display>
<contributor-id type="github">vidierr</contributor-id>
</contributor>
<contributor id="rohit.raveendran"> <contributor id="rohit.raveendran">
<contributor-name-display>Rohit Raveendran</contributor-name-display> <contributor-name-display>Rohit Raveendran</contributor-name-display>
<contributor-id type="github">rohitrav33ndran</contributor-id> <contributor-id type="github">rohitrav33ndran</contributor-id>

View File

@ -275,8 +275,6 @@ httpResponseNew(HttpSession *session, const String *verb, bool contentCache)
String *headerKey = strLower(strTrim(strSubN(header, 0, (size_t)colonPos))); String *headerKey = strLower(strTrim(strSubN(header, 0, (size_t)colonPos)));
String *headerValue = strTrim(strSub(header, (size_t)colonPos + 1)); String *headerValue = strTrim(strSub(header, (size_t)colonPos + 1));
httpHeaderAdd(this->pub.header, headerKey, headerValue);
// Read transfer encoding (only chunked is supported) // Read transfer encoding (only chunked is supported)
if (strEq(headerKey, HTTP_HEADER_TRANSFER_ENCODING_STR)) if (strEq(headerKey, HTTP_HEADER_TRANSFER_ENCODING_STR))
{ {
@ -300,8 +298,11 @@ httpResponseNew(HttpSession *session, const String *verb, bool contentCache)
// If the server notified of a closed connection then close the client connection after reading content. This // If the server notified of a closed connection then close the client connection after reading content. This
// prevents doing a retry on the next request when using the closed connection. // prevents doing a retry on the next request when using the closed connection.
if (strEq(headerKey, HTTP_HEADER_CONNECTION_STR) && strEq(headerValue, HTTP_VALUE_CONNECTION_CLOSE_STR)) if (strEq(headerKey, HTTP_HEADER_CONNECTION_STR) && strEq(strLower(headerValue), HTTP_VALUE_CONNECTION_CLOSE_STR))
this->closeOnContentEof = true; this->closeOnContentEof = true;
// Add after header checks in case the value was modified
httpHeaderAdd(this->pub.header, headerKey, headerValue);
} }
while (1); while (1);

View File

@ -638,7 +638,7 @@ testRun(void)
hrnServerScriptExpectZ( hrnServerScriptExpectZ(
http, "GET /path/file%201.txt HTTP/1.1\r\n" TEST_USER_AGENT "content-length:30\r\n\r\n" http, "GET /path/file%201.txt HTTP/1.1\r\n" TEST_USER_AGENT "content-length:30\r\n\r\n"
"012345678901234567890123456789"); "012345678901234567890123456789");
hrnServerScriptReplyZ(http, "HTTP/1.1 200 OK\r\nConnection:close\r\n\r\n01234567890123456789012345678901"); hrnServerScriptReplyZ(http, "HTTP/1.1 200 OK\r\nConnection:ClosE\r\n\r\n01234567890123456789012345678901");
hrnServerScriptClose(http); hrnServerScriptClose(http);