1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-06-14 23:44:58 +02:00

Improve the HTTP client to set content-length to 0 when not specified by the server.

S3 (and gateways) always set content-length or transfer-encoding but HTTP 1.1 does not require it and proxies (e.g. HAProxy) may not include either.

Suggested by Adam K. Sumner.
This commit is contained in:
David Steele
2018-06-26 17:27:22 -04:00
parent e8c68b9c66
commit 7b0e65d488
4 changed files with 13 additions and 29 deletions

View File

@ -148,10 +148,10 @@ sub run
$self->httpsServer(sub
{
$self->httpsServerAccept();
$self->{oConnection}->write("HTTP/1.1 200 NoContentLengthMessage1\r\n\r\n");
$self->{oConnection}->write("HTTP/1.1 404 Error\r\nBogus-Header\r\n\r\n");
$self->httpsServerAccept();
$self->{oConnection}->write("HTTP/1.1 200 NoContentLengthMessage2\r\n\r\n");
$self->{oConnection}->write("HTTP/1.1 404 Error\r\nBogus-Header\r\n\r\n");
$self->httpsServerAccept();
$self->httpsServerResponse(200, $strTestData);
@ -161,7 +161,7 @@ sub run
$self->testException(
sub {new pgBackRest::Common::Http::Client(
$strTestHost, HTTP_VERB_GET, {iPort => HTTPS_TEST_PORT, bVerifySsl => false, iTryTotal => 1})},
ERROR_PROTOCOL, 'content-length or transfer-encoding must be defined');
ERROR_PROTOCOL, "http header 'Bogus-Header' requires colon separator");
$self->testResult(
sub {new pgBackRest::Common::Http::Client(