Comments (10)
According to RFC-7230 require header-value to be at least 1 character long. Or am I mistaken?
from psr7.
This looks like we made a mistake, thanks for spotting it!
As discussed in #38, empty headers are very much allowed. But then in #48 this was undone. Oops!
Well spotted. I’ll add a test to the test suite so it (hopefully) wont happen again.
from psr7.
@Nyholm, sorry, looks like you were commenting at the same time as me 😉 You are mistaken, you can check the ABNF in the comment block included above our code: the field-value starts with a *
and is optional.
from psr7.
Okey. Thank you. That should be fixed then.
Could @TiMESPLiNTER submit a PR?
from psr7.
I would just remove the excpetions for empty headers then and write a test case for it?
Or should I build a regex out of this pattern taken from the RFC:
*( ( %x21-7E / %x80-FF ) [ 1*( SP / HTAB ) ( %x21-7E / %x80-FF ) ] )
from psr7.
Uuhm. I just wrote the following test and it passes:
public function testCanHaveHeaderWithEmptyValue()
{
$r = new Request('GET', 'https://example.com/');
$r = $r->withHeader('Foo', '');
$this->assertEquals('', $r->getHeaderLine('Foo'));
}
Are you sure you are using the latest version of the library?
from psr7.
Oops, sorry! I use https://github.com/kriswallsmith/Buzz which still uses 0.3
. I'll do a PR over there to update the dependency.
I leave this Issue open as you may want to attach your testcase to it?
from psr7.
Ah I just saw @Nyholm already commited that to Buzz and it's in master. So let's hope we will get a new release soon.
from psr7.
I’ll PR tests for empty header name and empty header value in a minute.
@Nyholm is this worth PR’ing to the integration tests instead? In \Psr\Http\Message\MessageInterface\MessageTrait::testWithHeaderInvalidArguments
it seems to cover the empty header name (which is not allowed), but I don’t see it cover empty header values anywhere?
from psr7.
Opened a PR against the integration tests as well. See php-http/psr7-integration-tests#30.
from psr7.
Related Issues (20)
- Broken PSR-7 immutability HOT 2
- argument name of withHeader() is inconsistent with PSR-7 definition. HOT 2
- feature request for a non-buffered stream (NonBufferedStream) HOT 3
- Empty body when using psr17factory's createRequest HOT 3
- Filter Uri->withUserInfo() input HOT 2
- Axios get request gives [AxiosError:Network Error] & Error: header name must be a non-empty string
- Response::__toString() HOT 2
- Integration tests errors HOT 2
- Escaping of user info breaks NTLM authentication HOT 9
- "Site not found" for https://tnyholm.se HOT 2
- psr/http-message 版本问题 HOT 4
- PSR/HTTP message incompatibility 2.0 on nyholm/psr7 server HOT 1
- Breaking change from 1.5.1 => 1.6.0 due to fseek on new streams? HOT 3
- https://packagist.org/packages/php-http/message-factory dependand package abandoned HOT 1
- Segmentation Error while using Elasticsearch php's library bulk method HOT 2
- php-http/message-factory HOT 2
- Empty host value not allowed HOT 1
- For what reason message trait contains original header names?
- Support for "Early Hints" / HTTP Code 103 HOT 1
- Request getSize() returns null for php://input stream HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from psr7.