http-kit icon indicating copy to clipboard operation
http-kit copied to clipboard

Incorrect response when POSTing multipart/form-data

Open dmichulke opened this issue 8 years ago • 2 comments

I have a small function that does the following

(POST "/testpost"
       []
       (-> (ring.util.response/response "asdasd")
           (ring.util.response/status 400)))

Now when I do

curl -v --form a=b localhost:3000/testpost

I get

< Server: http-kit
< HTTP/1.1 400 Bad Request
< Content-Length: 8
...
< Server: http-kit
* HTTP error before end of send, stop sending
< 
* Closing connection 0
"asdasd"

However,

  • if I use curl --data (i.e., form encoded) instead of curl --form it works (I get no HTTP error before end of send)
  • if I respond with status 200 instead of 400 it works
  • if I use curl option -0 (= HTTP 1.0 instead of 1.1) it doesn't work

I write here because when I do the same thing in tests (using ring mock/request to call the handler directly), the problem also does not occur.

dmichulke avatar Oct 17 '16 15:10 dmichulke

I have also just started to encounter a very similar problem with multi-part requests. Reducing the timeout causes the request to be timed out, but it doesn't look to see if it has a response.

I hacked the clearTimeout method in HttpClient to perform the read operations instead of finishing with the timeout exception and this seems to confirm this idea.

I started to look into trying to fix this, but the way http-kit treats large requests doesn't fit my use-case and that seems like a much larger issue, too large for my time.

tcoupland avatar Dec 07 '16 13:12 tcoupland

I can confirm that multipart on http-kit is pretty much useless. I have to use clj-http for that.

zilti avatar Feb 08 '20 23:02 zilti