httpserver.h icon indicating copy to clipboard operation
httpserver.h copied to clipboard

server crashes with certain image/media payloads

Open mattfeury opened this issue 5 years ago • 2 comments

hi! thanks for this server. it is really impressive and helpful.

i'm trying to set it up to send some media data to a device via a POST. i'm able to make an empty file of X bytes and send it successfully:

$ mkfile -n 76369 76369.txt
$ curl -X POST -v --data-binary @76369.txt  "http://192.168.7.58:9000/"
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 192.168.7.58...
* TCP_NODELAY set
* Connected to 192.168.7.58 (192.168.7.58) port 9000 (#0)
> POST / HTTP/1.1
> Host: 192.168.7.58:9000
> User-Agent: curl/7.64.1
> Accept: */*
> Content-Length: 76369
> Content-Type: application/x-www-form-urlencoded
> Expect: 100-continue
> 
* Done waiting for 100-continue
* We are completely uploaded and fine
< HTTP/1.1 200 OK
< Date: Mon, 21 Sep 2020 16:53:30 GMT
< Connection: keep-alive
< Content-Type: text/plain
< Content-Length: 13
< 
* Connection #0 to host 192.168.7.58 left intact
Hello, World!* Closing connection 0

however. when i try to do this same request with a .png, .jpeg, .mkv, etc, i will often see failures. below is a file of the same size:

$ curl -X POST -v --data-binary @image.jpg  "http://192.168.7.58:9000/"
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 192.168.7.58...
* TCP_NODELAY set
* Connected to 192.168.7.58 (192.168.7.58) port 9000 (#0)
> POST / HTTP/1.1
> Host: 192.168.7.58:9000
> User-Agent: curl/7.64.1
> Accept: */*
> Content-Length: 76369
> Content-Type: application/x-www-form-urlencoded
> Expect: 100-continue
> 
* Done waiting for 100-continue
* We are completely uploaded and fine
* Recv failure: Connection reset by peer
* Closing connection 0
curl: (56) Recv failure: Connection reset by peer

any thoughts as to why this is happening and how i can fix? maybe a character encoding issue?

thanks!

mattfeury avatar Sep 21 '20 16:09 mattfeury

Sorry for the late response. I'd be curious to know more but I can't reproduce the issue. Do you have a file that you wouldn't mind sharing that can reproduce the problem?

jeremycw avatar Jan 13 '21 20:01 jeremycw

Cloud be that https://github.com/jeremycw/httpserver.h/pull/53 solves this issue.

userhdisk avatar Aug 23 '22 20:08 userhdisk