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

Remove check for empty header string value #35

Merged
merged 1 commit into from Apr 16, 2018

Conversation

sunkan
Copy link
Contributor

@sunkan sunkan commented Apr 16, 2018

I was using Buzz when I got an exception about empty header value.
When I tried to use Zend Diactoros instead of this library it worked as expected.

If you'r interested I can put together a better fix that dose the validating more like it's done in Zend Diactoros

Should probably be change to a proper check that allows empty value but
validates the value like it's done in Zend Diactoros
https://github.com/zendframework/zend-diactoros/blob/master/src/HeaderSecurity.php#L96-L120
@Nyholm
Copy link
Owner

Nyholm commented Apr 16, 2018

You are correct. Thank you for this fix.

@Nyholm Nyholm merged commit b546d2f into Nyholm:master Apr 16, 2018
@Zegnat
Copy link
Collaborator

Zegnat commented Apr 16, 2018

Should the Exception messages be updated after this, if this now allows empty header values? (Also interesting how this could be done without tripping up any tests, clearly something not being tested.)

@Nyholm
Copy link
Owner

Nyholm commented Apr 16, 2018

Exception messages should not be updated. The PR enforce that empty headers should NOT be added.

About tests:
Yes, I'm also curious. This PR adds checks for $request->withAddedHeader('name', ['foobar', '']);
I know we have tests for $request->withAddedHeader('name', '');

@Nyholm
Copy link
Owner

Nyholm commented Apr 17, 2018

Oh. I misread this PR. Martin, you are correct. We should update exception message.

@Nyholm
Copy link
Owner

Nyholm commented Apr 18, 2018

Sunkan, thank you for the chat yesterday and sorry for prematurely merging this PR.

Could you improve the code by updating the exception messages and reference the RFC that specifies the header value? (Or where it says the value can be empty)

@sunkan
Copy link
Contributor Author

sunkan commented Apr 18, 2018

It looks like the RFC-7230 require header-value to be at least 1 charecter long. But I might be wrong.

What I can find most clients/librarys allow sending of empty header values

  • curl allow you to send empty headers
  • Firefox allows it for xhr/fetch with the motivation We need it to be compliant with the XHR spec: "The empty string is legal and represents the empty header value."
  • From the firefox thread it seams like Chrome also support sending and reciving empty header values
  • Guzzle support sending empty header-value Empty headers support guzzle/guzzle#1915

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.

None yet

3 participants