httpserver.h
httpserver.h copied to clipboard
server crashes with certain image/media payloads
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!
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?
Cloud be that https://github.com/jeremycw/httpserver.h/pull/53 solves this issue.