Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[HttpClient] Psr18Client can't get custom HTTP status messages #51527

Closed
@Hanmac

Description

@Hanmac

Symfony version(s) affected

5,4, 6.4

Description

for example if some API i want to connect uses HTTP Status Codes like this:

HTTP/1.1 404 countryCodeNotFound

then when using Symfony HttpClient as its own Client, then the Exception sets the Message correct

but the Psr18Client doesn't parse the response_headers like the Exceptions do
https://github.com/symfony/symfony/blob/6.4/src/Symfony/Component/HttpClient/Exception/HttpExceptionTrait.php#L34

the Psr18Client sets the status code without trying to set the message too:
https://github.com/symfony/symfony/blob/6.4/src/Symfony/Component/HttpClient/Psr18Client.php#L108

How to reproduce

have an API with custom status messages:

HTTP/1.1 404 countryCodeNotFound

Possible Solution

Similar code that is done in the Exception Trait should also be done in the Psr18Client

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions