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

Invalid validation of Response codes #64

Closed
ShurikAg opened this issue May 29, 2012 · 3 comments
Closed

Invalid validation of Response codes #64

ShurikAg opened this issue May 29, 2012 · 3 comments

Comments

@ShurikAg
Copy link

When response object is created constructor validates response code against hardcoded list:

Guzzle\Http\Message\Response

public function __construct($statusCode, $headers = null, $body = null)
    {
        if (!array_key_exists($statusCode, self::$statusTexts)) {
            throw new BadResponseException(
                'Invalid response code: ' . $statusCode
            );
        }
   ...

and if the code is not in the list a BadResponseException is thrown.

This means that there is no way to use custom codes (like in our case), not even to mention that the list is far from the full list of available standard codes.

I see the intention of this list: to provide proper translation mechanism for the codes, however it should not be used for validation, especially when these is no easy way around it.

@mtdowling
Copy link
Member

Agreed. I'll push a fix in a few minutes.

@ShurikAg
Copy link
Author

Which version it went into?

@mtdowling
Copy link
Member

It's in master right now. I haven't tagged it in a release yet, but I'll probably tag a release tomorrow night.

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