Wireshark
I was composing a http request with cURL in PHP, posting username and password to a user authentication url to get a token, which is actually exactly what users do to log onto a website. But I got stuck in a 401 error, I was told 'unauthorized' all the time even I was pretty sure I had typed in the correct user-name & password, which I could sign in with, but failed to do that with PHP.
So, this is where I need Wireshark. And what I did was to log into my site from browser, say, Chrome, and with Wireshark monitoring and recording the network traffic; and then do the same request from PHP.
Now, I have captured the two HTTP requests, one of which is successful, the other is a failure. And compare them in details, then, field by field. Like demonstrated as following:
As shown, the difference of HTTP fields were highlighted on the right, which were absent in the HTTP request from my PHP script, and that is the reason I was looking for.
How to do that?
How to set capture filter based on ip addresses of hosts:
In case you dont know how to look up the ip address of a domain name:
How to filter by ip address
How to pick the packets out with protocol being TLSv1.2:
You can find out the version number by inspecting the detail of one package:
Fiddler
If you would like to create a POST request with data, just as if you are submitting data through a web form, then you must add the string:Content-Type: application/x-www-form-urlencoded.
You can refer to Send POST request to asp.net mvc action via Fiddler