2

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-APP_PROFILE: 8
X-Protocol: 2
X-VAYO-LANG: he
X-IMEI: [REDACTED]
X-Handset_Platform: ANDROID
X-IMSI: [REDACTED]    
X-PID: [REDACTED]    
X-VAYO-ID: 1    
Content-Type: application/x-www-form-urlencoded;charset=UTF-8    
Content-Length: 3    
Host: [REDACTED]    

n=v
2
  • 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, 2019 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, 2019 at 21:25

2 Answers 2

3

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
2
  • Useless use of cat in both examples? <request.txt nc host 80 Oct 4, 2019 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. Oct 4, 2019 at 11:37
1

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.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .