Skip to content

Conversation

@krwu
Copy link
Contributor

@krwu krwu commented Jan 1, 2018

$host   = explode('.', $request->getHost());
$bucket = (count($host) === 4) ? $host[0] : array_shift($path);
$object = array_shift($path);
if ($bucket && $object) {
    $data['code'] = 'NoSuchKey';
} elseif ($bucket) {
    $data['code'] = 'NoSuchBucket';
}

The host should be '{bucket}-{appid}.cos.{region}.myqcloud.com' for XML API. It means count(explode('.', $request->getHost()) equals 5, not 4(That's JSON API's value). This make $bucket always be array_shift($path), and $object always null;

I changed the condition from count($host) === 4 to count($host) >= 4. It could resolve #32.

@lewzylu lewzylu merged commit b8131bf into tencentyun:master Jan 2, 2018
@lewzylu
Copy link
Contributor

lewzylu commented Jan 2, 2018

Thank you for your contribution here has been tested

@krwu krwu deleted the fix-exception-mismatch branch May 23, 2018 03:57
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

Successfully merging this pull request may close these issues.

Bug: 'NoSuchBucket' Exception is thrown when an object doesn't exists.

2 participants