Hello ! Tell me please, is it possible to somehow see which POST request generates curl by the passed parameters?
2 answers
No, unfortunately, the curl extension does not have such a native capability. But you can send a request somewhere to the program under your control and see what exactly came. For example, the simplest way is to open the port via nc :
nc -l -p 12345 Then in the code, replace the URL with this local address:
$ch = curl_init('http://127.0.0.1:12345'); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => ['foo' => 1], ]); $response = curl_exec($ch); When you run this code, the exact request sent will appear on the console with nc :
melkij@melkij:~$ nc -l -p 12345 POST / HTTP/1.1 Host: 127.0.0.1:12345 Accept: */* Content-Length: 139 Expect: 100-continue Content-Type: multipart/form-data; boundary=------------------------05be5d432625f809 --------------------------05be5d432625f809 Content-Disposition: form-data; name="foo" 1 --------------------------05be5d432625f809-- - Thank you Helped - Bogdan Gudyma
|
Use the -v option
curl -v google.com |
------WebKitFormBoundaryibLm7G5cqxCOuAFy Content-Disposition: form-data; name="file"; filename="1-g-0-032-oz-silver-valcambi-bullion-bar-999-rev.jpg" Content-Type: image/jpeg ------WebKitFormBoundaryibLm7G5cqxCOuAFy Content-Disposition: form-data; name="scrid" 32482346-7100587438898460646 ------WebKitFormBoundaryibLm7G5cqxCOuAFy--------WebKitFormBoundaryibLm7G5cqxCOuAFy Content-Disposition: form-data; name="file"; filename="1-g-0-032-oz-silver-valcambi-bullion-bar-999-rev.jpg" Content-Type: image/jpeg ------WebKitFormBoundaryibLm7G5cqxCOuAFy Content-Disposition: form-data; name="scrid" 32482346-7100587438898460646 ------WebKitFormBoundaryibLm7G5cqxCOuAFy--------WebKitFormBoundaryibLm7G5cqxCOuAFy Content-Disposition: form-data; name="file"; filename="1-g-0-032-oz-silver-valcambi-bullion-bar-999-rev.jpg" Content-Type: image/jpeg ------WebKitFormBoundaryibLm7G5cqxCOuAFy Content-Disposition: form-data; name="scrid" 32482346-7100587438898460646 ------WebKitFormBoundaryibLm7G5cqxCOuAFy--question is, can I see what will be generated when sent to the server to compare the request and the answer. I apologize for the formatting. - Bogdan Gudyma