Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S3Client::doesBucketExist() always return true using GuzzleHandler with StreamHandler #693

Closed
okinaka opened this issue Jul 16, 2015 · 2 comments

Comments

@okinaka
Copy link

okinaka commented Jul 16, 2015

I try to use GuzzleHandler with StreamHandler for avoiding to use curl module.
But S3Client::doesBucketExist() and doesObjectExist() return invalid results.

$handler = new \Aws\Handler\GuzzleV6\GuzzleHandler(
  new \GuzzleHttp\Client(['handler' => new \GuzzleHttp\Handler\StreamHandler()])
);
$client = new \Aws\S3\Client(['http_handler' => $handler, ...]);

$actual = $client->doesBucketExist('invalid bucket name'); // => return true (always).

Because GuzzleHandler (using StreamHandler) is fulfilled when response status code is 404 .
here: https://github.com/aws/aws-sdk-php/blob/master/src/Handler/GuzzleV6/GuzzleHandler.php#L42

jeskew pushed a commit to jeskew/aws-sdk-php that referenced this issue Jul 16, 2015
@mtdowling
Copy link
Member

You need to ensure that the handler you use with the SDK is throwing an exception when a non-200/300 response is received. This can be done when creating the Guzzle handler.

use Aws\Handler\GuzzleV6\GuzzleHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Handler\StreamHandler;

$handler = HandlerStack::create(new StreamHandler);
$wrappedHandler = GuzzleHandler($handler);
$client = new \Aws\S3\Client(['http_handler' => $wrappedHandler]);

@okinaka
Copy link
Author

okinaka commented Jul 17, 2015

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants