Home > OS >  C (cpp-netlib) http listener - how to remove headers
C (cpp-netlib) http listener - how to remove headers

Time:03-28

I created an HTTP listener that accepts POST requests for files. I followed this template almost exactly: enter image description here

CodePudding user response:

body__ does not get populated with header data. What you see is multipart data that you submit with --form <name=content>. If you want submit raw file data use another curl command:

curl --data-binary "@file1.txt"  -H "Content-Type: application/octet-stream" http://127.0.0.1:8000/

-X POST can be omitted if is used with --data-binary, --data, --form.

Unfortunately curl does not send a file name. If a file name is required on a server side, specify the header Content-Disposition:

curl --data-binary "@file1.txt"  -H "Content-Type: application/octet-stream" -H "Content-Disposition: attachment; filename=file1.txt" http://127.0.0.1:8000/

KB

  1. --data-binary
  2. -F, --form
  • Related