We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3024522 commit 0c18616Copy full SHA for 0c18616
src/AbstractApi.php
@@ -136,7 +136,16 @@ final protected function getResponse(Request $request, ?RequestContext $context
136
]
137
);
138
139
- return new Response($response, $this->httpClient, $this->logger);
+ if ($debug = \filter_var($this->configuration->get('debug'), \FILTER_VALIDATE_BOOLEAN)) {
140
+ $this->logger->debug('AsyncAws HTTP request sent: {method} {endpoint}', [
141
+ 'method' => $request->getMethod(),
142
+ 'endpoint' => $request->getEndpoint(),
143
+ 'headers' => json_encode($request->getHeaders()),
144
+ 'body' => 0 === $length ? null : $requestBody,
145
+ ]);
146
+ }
147
+
148
+ return new Response($response, $this->httpClient, $this->logger, $debug);
149
}
150
151
/**
src/Configuration.php
@@ -17,6 +17,7 @@ final class Configuration
17
public const DEFAULT_REGION = 'us-east-1';
18
19
public const OPTION_REGION = 'region';
20
+ public const OPTION_DEBUG = 'debug';
21
public const OPTION_PROFILE = 'profile';
22
public const OPTION_ACCESS_KEY_ID = 'accessKeyId';
23
public const OPTION_SECRET_ACCESS_KEY = 'accessKeySecret';
@@ -34,6 +35,7 @@ final class Configuration
34
35
36
private const AVAILABLE_OPTIONS = [
37
self::OPTION_REGION => true,
38
+ self::OPTION_DEBUG => true,
39
self::OPTION_PROFILE => true,
40
self::OPTION_ACCESS_KEY_ID => true,
41
self::OPTION_SECRET_ACCESS_KEY => true,
@@ -69,6 +71,7 @@ final class Configuration
69
71
70
72
private const DEFAULT_OPTIONS = [
73
self::OPTION_REGION => self::DEFAULT_REGION,
74
+ self::OPTION_DEBUG => 'false',
75
self::OPTION_PROFILE => 'default',
76
self::OPTION_SHARED_CREDENTIALS_FILE => '~/.aws/credentials',
77
self::OPTION_SHARED_CONFIG_FILE => '~/.aws/config',
src/Response.php
@@ -68,11 +68,17 @@ class Response
68
*/
private $logger;
- public function __construct(ResponseInterface $response, HttpClientInterface $httpClient, LoggerInterface $logger)
+ /**
+ * @var bool
+ */
+ private $debug;
+ public function __construct(ResponseInterface $response, HttpClientInterface $httpClient, LoggerInterface $logger, bool $debug = false)
{
78
$this->httpResponse = $response;
79
$this->httpClient = $httpClient;
80
$this->logger = $logger;
81
+ $this->debug = $debug;
82
83
84
public function __destruct()
@@ -114,6 +120,21 @@ public function resolve(?float $timeout = null): bool
114
120
$this->resolveResult = new NetworkException('Could not contact remote server.', 0, $e);
115
121
116
122
123
+ if (true === $this->debug) {
124
+ $httpStatusCode = $this->httpResponse->getInfo('http_code');
125
+ if (0 === $httpStatusCode) {
126
+ // Network exception
127
+ $this->logger->debug('AsyncAws HTTP request could not be sent due network issues');
128
+ } else {
129
+ $this->logger->debug('AsyncAws HTTP response received with status code {status_code}', [
130
+ 'status_code' => $httpStatusCode,
131
+ 'headers' => json_encode($this->httpResponse->getHeaders(false)),
132
+ 'body' => $this->httpResponse->getContent(false),
133
134
+ $this->bodyDownloaded = true;
135
117
return $this->getResolveStatus();
118
119
0 commit comments