Coder Social home page Coder Social logo

Comments (7)

emmanueltouzery avatar emmanueltouzery commented on September 27, 2024

well yes I think the problem is there.

specifically to parse cookies from the server, the server returns them on two lines according to curl:

Set-Cookie: _redmine_session=blabla; path=/; HttpOnly
Set-Cookie: autologin=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT

And the following code:
main = do
maybeCookie <- login username password
print $ fromJust maybeCookie

-- returns the cookie
login :: ByteString -> ByteString -> IO (Maybe ByteString)
login username password = do
postForm
(BS.concat [serverUrl, "login"])
[("username", username), ("password", password)]
getCookies

getCookies :: Response -> InputStream ByteString -> IO (Maybe ByteString)
getCookies r i = return $ getHeader r "Set-Cookie"

.. that programs prints only:
"autologin=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT"

I'll see if I can add a test showing the problem. First I'll try to run the existing tests.

from http-streams.

istathar avatar istathar commented on September 27, 2024

Thanks for demonstrating the problem, @emmanueltouzery Yes, a test case would be very helpful indeed.

AfC

from http-streams.

emmanueltouzery avatar emmanueltouzery commented on September 27, 2024

I submitted a pull request, #14

Running the updated tests now print for me:
Parsing responses multiline response headers are properly parsed FAILED
Invalid response headers
expected: Just "line1\nline2"
but got: Just "line2"

Note that however many tests still fail for me, even though "host localhost" now returns 127.0.0.1. But I can test by replacing "localhost" by 127.0.0.1 in the tests (that workaround is not in the pull request obviously).

from http-streams.

istathar avatar istathar commented on September 27, 2024

Thanks for your patch on #14. I'll merge it. However, we still need a test that shows (our failure to parse correctly) a single HTTP header that flows over multiple lines ("continuation line", per RFC 2616 ยง2.2)

AfC

from http-streams.

istathar avatar istathar commented on September 27, 2024

Meanwhile, from the last paragraph of RFC 2616 ยง4.2),

Multiple message-header fields with the same field-name MAY be
present in a message if and only if the entire field-value for that
header field is defined as a comma-separated list [i.e., #(values)].
It MUST be possible to combine the multiple header fields into one
"field-name: field-value" pair, without changing the semantics of the
message, by appending each subsequent field-value to the first, each
separated by a comma.

so I'll have to amend your test case...

AfC

from http-streams.

hvr avatar hvr commented on September 27, 2024

Which kind of multi-line header is this ticket about?

  1. Is this about multiple header fields as in

    Server: Apache/2.0.48 (Unix) DAV/2 SVN/1.0.0 Catacomb/0.9.0 PHP/5.0.0b4 mod_ssl/2.0.48 OpenSSL/0.9.6e
    DAV: 1,2
    DAV: version-control,checkout, checkin, report
    DAV: uncheckout,version-controlled-collection
    DAV: <http://apache.org/dav/propset/fs/1>
    MS-Author-Via: DAV
    
  2. ..or rather about continuation lines such as in

    Server: xy
    X-Foo: 1st line of x-foo
     2nd line of x-foo
     3rd and last line of x-foo
    Content-Type: plain/text
    

?

from http-streams.

istathar avatar istathar commented on September 27, 2024

Which kind of multi-line header is this ticket about?

It started out as (2) but @emmanueltouzery hijacked it and now it is about (1) :)

I've been meaning to open a new bug for (2) as continuation lines need to be supported properly.

AfC

from http-streams.

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.