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

Are response headers returned by HTTP client expected to be flat or not? #992

Closed
ostrolucky opened this issue Aug 9, 2020 · 4 comments
Closed

Comments

@ostrolucky
Copy link
Contributor

Hi, I'm building PSR-18 adapter for stripe-php and it's unclear if Stripe\HttpClient\ClientInterface::request method should return flat list of headers, or PSR-7 style headers where headers with multiple values are grouped under same key as another array value. So basically, should list of headers be array<string, string>, or array<string, list<string>>?

My confusion lies because your test cases assert for flat values

$this->assertSame('req_123', $rheaders['request-id']);
but your code expects multi dimensional list
$rheaders['request-id'][0],

And as far as I can see, the code given is the only time your library happens to read response headers.

@ctrudeau-stripe
Copy link
Contributor

Hello @ostrolucky, as far as we can tell it is always flat. This alerted us to a bug in our telemetry reporting. Thank you for pointing it out!

@ostrolucky
Copy link
Contributor Author

ostrolucky commented Aug 14, 2020

Alright. And what's the expectation when server returns multiple values for same header name? Eg.

Set-Cookie: PHPSESSID=abc; path=/
Set-Cookie: PHPSESSID=def; path=/
Set-Cookie: PHPSESSID=ghi; path=/
Link: </2012/07/26/csstests/csshttplink.css>;rel=stylesheet
Link: </>;rel=next

@richardm-stripe
Copy link
Contributor

The current behavior seems to be that it sets the value equal to the last header specified.

@ostrolucky
Copy link
Contributor Author

Alright thx, I'll make my adapter to behave same way

ostrolucky added a commit to psr18-adapter/stripe-php that referenced this issue Aug 15, 2020
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

3 participants