Code Monkey home page Code Monkey logo

Comments (10)

Nyholm avatar Nyholm commented on May 22, 2024

According to RFC-7230 require header-value to be at least 1 character long. Or am I mistaken?

from psr7.

Zegnat avatar Zegnat commented on May 22, 2024

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.

Zegnat avatar Zegnat commented on May 22, 2024

@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.

Nyholm avatar Nyholm commented on May 22, 2024

Okey. Thank you. That should be fixed then.
Could @TiMESPLiNTER submit a PR?

from psr7.

TiMESPLiNTER avatar TiMESPLiNTER commented on May 22, 2024

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.

Zegnat avatar Zegnat commented on May 22, 2024

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.

TiMESPLiNTER avatar TiMESPLiNTER commented on May 22, 2024

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.

TiMESPLiNTER avatar TiMESPLiNTER commented on May 22, 2024

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.

Zegnat avatar Zegnat commented on May 22, 2024

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.

Zegnat avatar Zegnat commented on May 22, 2024

Opened a PR against the integration tests as well. See php-http/psr7-integration-tests#30.

from psr7.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.