I am sending an XML SOAP request via CURL in PHP.
Is there a way of viewing (print_r/var_dump) the entire request including headers before sending it?
We can use curl -v or curl -verbose to display the request headers and response headers in the cURL command. The > lines are request headers . The < lines are response headers .
curl_getinfo — Get information regarding a specific transfer.
curl_exec(CurlHandle $handle ): string|bool. Execute the given cURL session. This function should be called after initializing a cURL session and all the options for the session are set.
See CURLOPT_VERBOSE
. But I don't think you will be able to get anything from it until the request has been completed.
curl_setopt($curl, CURLOPT_VERBOSE, true);
See the PHP manual page for curl_setopt()
for the options.
You can set curl_setopt($request, CURLINFO_HEADER_OUT, TRUE);
and then after curl_exec($request);
see the request sent with echo curl_getinfo($request, CURLINFO_HEADER_OUT)
. But it only works AFTER the request is sent. I don't think it's possible to get what is going to be sent before actually executing it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With