Skip to content
This repository

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

Closed
j3h opened this Issue April 21, 2011 · 2 comments

2 participants

j3h Gregory Collins
j3h
j3h commented April 21, 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.

Gregory Collins
Owner

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

Gregory Collins gregorycollins closed this in 6e76622 April 30, 2011
Gregory Collins
Owner

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
Something went wrong with that request. Please try again.