I want to mimic a HTTP POST request that I intercepted and have raw on a file, what would be the best way to send it and be certain that I sent exactly the same request?

example file: (private data redacted obviously)

POST /mobile/testAPN.ashx HTTP/1.1
Connection: close
User-Agent: [REDACTED]
Cache-Control: no-cache
Pragma: no-cache
Accept: */*
Accept-Encoding: identity
X-Protocol: 2
X-Handset_Platform: ANDROID
X-VAYO-ID: 1    
Content-Type: application/x-www-form-urlencoded;charset=UTF-8    
Content-Length: 3    
Host: [REDACTED]    

  • 1
    We don't know what your raw file looks like so there's no way for us to tell you exactly what to do. Postman is a good tool to send custom requests to a given URL. – Technidev Oct 3 '19 at 21:21
  • @Technidev gonna add an example raw file but the question is about any raw POST request not a specific one – Tom Oct 3 '19 at 21:25

If you want to replay the exact request you have in the file as plain HTTP you can simply use netcat:

cat request.txt | nc host 80

If you want to replay it as HTTPS instead of HTTP you can use openssl s_client:

cat request.txt | openssl s_client -connect host:443 -servername host
  • Useless use of cat in both examples? <request.txt nc host 80 – multithr3at3d Oct 4 '19 at 11:18
  • @multithr3at3d: yes, it is useless use of cat and one could also argue that -servername is not needed with modern s_client. But, it is easier to understand this why what is going on since the input is put in front of the main command and not as some long command with arguments < input. – Steffen Ullrich Oct 4 '19 at 11:37

curl is the tool for the job. You can view the documentation here as to how to pass all of the headers in the POST request that you have listed in your question. You'll want to use the -H option to pass the header parameters that you show.

If the request is initiated from Firefox or Chrome, you can follow these instructions to capture a curl command that is equivalent to the POST request made by the browser.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.