Connections cannot be reused if requests specify Content-Length: 0 #68

Closed
j3h opened this Issue Apr 22, 2011 · 2 comments

Comments

Projects
None yet
2 participants
@j3h

j3h commented Apr 22, 2011

I ran into some trouble when attempting to reuse a connection to a Snap server. I eventually narrowed it down to the following:

When send the following via netcat to my Snap server:

GET / HTTP/1.1
Host: localhost:8000
Content-Length: 0

GET / HTTP/1.1
Host: localhost:8000
Content-Length: 0

I only get one HTTP response. After digging for a while, I think the bug is in Snap.Iteratee.takeExactly's handling of zero-length input, but I am not sure.

I removed this case:

takeExactly 0   s = do
    s' <- lift $ runIteratee $ enumEOF s
    case s' of
      (Continue _) -> error "divergent iteratee"
      (Error e)    -> throwError e
      (Yield v _)  -> yield (Yield v EOF) EOF

because there is a case for zero further down, and it looked like it was behaving better.

@gregorycollins

This comment has been minimized.

Show comment
Hide comment
@gregorycollins

gregorycollins Apr 22, 2011

Member

Looks good to me. Could you please send a pull request? I will apply it.

Member

gregorycollins commented Apr 22, 2011

Looks good to me. Could you please send a pull request? I will apply it.

@gregorycollins

This comment has been minimized.

Show comment
Hide comment
@gregorycollins

gregorycollins Apr 30, 2011

Member

Could you please verify that the fix works? Thanks!

Member

gregorycollins commented Apr 30, 2011

Could you please verify that the fix works? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment