Skip to content
Discussion options

You must be logged in to vote

I believe it's hanging because your code doesn't take into account the number of bytes that have already been read from the socket when it decides to read. The Spork HTTP framework has to read from the socket at least once in order to parse the headers out, and it looks like it always reads in chunks of 4kb. So if you send a request with headers smaller than 4kb, part of the body has already been consumed (and put into (req :buffer)), so you can't read content-length more bytes from the socket.

Instead, you can use http/read-body, which takes into account the bytes already read and only issues additional read calls if it needs to.

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by l04m33
Comment options

You must be logged in to vote
1 reply
@bakpakin
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants