From f596702c5badb5dbd3b15b6c4ee0e54444ab6e8c Mon Sep 17 00:00:00 2001 From: David Steele Date: Wed, 21 Jun 2017 20:46:49 -0400 Subject: [PATCH] Improve S3 error reporting. --- doc/xml/release.xml | 4 ++++ lib/pgBackRest/Common/Http/Client.pm | 6 ++++-- lib/pgBackRest/Storage/S3/Request.pm | 4 +++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/doc/xml/release.xml b/doc/xml/release.xml index 465f16f4a..c7859a2d3 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -182,6 +182,10 @@

Remove support for 8.3.

+ + +

Improve S3 error reporting.

+
diff --git a/lib/pgBackRest/Common/Http/Client.pm b/lib/pgBackRest/Common/Http/Client.pm index d5baf3d3e..e6e8eda8c 100644 --- a/lib/pgBackRest/Common/Http/Client.pm +++ b/lib/pgBackRest/Common/Http/Client.pm @@ -127,13 +127,13 @@ sub new # Read the response headers $self->{iContentLength} = undef; - my $strResponseHeader = ''; + $self->{strResponseHeader} = ''; my $strHeader = trim($self->readLine()); while ($strHeader ne '') { # Validate header - $strResponseHeader .= "${strHeader}\n"; + $self->{strResponseHeader} .= "${strHeader}\n"; my $iColonPos = index($strHeader, ':'); @@ -275,8 +275,10 @@ sub responseBody # Properties. #################################################################################################################################### sub contentLength {shift->{iContentLength}} # Content length if available (-1 means not known yet) +sub requestHeaderText {trim(shift->{strRequestHeader})} sub responseCode {shift->{iResponseCode}} sub responseHeader {shift->{hResponseHeader}} +sub responseHeaderText {trim(shift->{strResponseHeader})} sub responseMessage {shift->{strResponseMessage}} sub responseProtocol {shift->{strResponseProtocol}} diff --git a/lib/pgBackRest/Storage/S3/Request.pm b/lib/pgBackRest/Storage/S3/Request.pm index 9bcf0eba6..dee954f11 100644 --- a/lib/pgBackRest/Storage/S3/Request.pm +++ b/lib/pgBackRest/Storage/S3/Request.pm @@ -186,7 +186,9 @@ sub request confess &log(ERROR, "S3 request error [$iReponseCode] " . $oHttpClient->responseMessage() . - (defined($$rstrResponseBody) ? ":\n${$rstrResponseBody}" : ''), + "\n*** request header ***\n" . $oHttpClient->requestHeaderText() . + "\n*** reponse header ***\n" . $oHttpClient->responseHeaderText() . + (defined($$rstrResponseBody) ? "\n*** response body ***\n${$rstrResponseBody}" : ''), ERROR_PROTOCOL); } }