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

Closed
j3h opened this Issue Apr 22, 2011 · 2 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
Member

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

@gregorycollins
Member

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