Open ramesh-tr opened 7 years ago
Steps to reproduce - Use the following sript
$hooks = new Requests_Hooks(); $hooks->register('fsockopen.before_send', function (&$data){ var_dump( $data ); }); $headers = array('Accept' => 'application/json'); $options = array('auth' => array('user', 'pass'), 'hooks' => $hooks, 'transport' => 'Requests_Transport_fsockopen'); $request = Requests::get('https://api.github.com/gists', $headers, $options); $request = Requests::get('https://api.github.com/gists', $headers, $options);
The result from the above script execution
string(221) "GET /gists HTTP/1.0 Host: api.github.com:443 User-Agent: php-requests/1.6.1 Accept-Encoding: deflate;q=1.0, compress;q=0.5, gzip;q=0.5 Accept: application/json Authorization: Basic dXNlcjpwYXNz Connection: Close " string(256) "GET /gists HTTP/1.0 Host: api.github.com:443 User-Agent: php-requests/1.6.1 Accept-Encoding: deflate;q=1.0, compress;q=0.5, gzip;q=0.5 Accept: application/json Authorization: Basic dXNlcjpwYXNz Authorization: Basic dXNlcjpwYXNz Connection: Close "
string(221) "GET /gists HTTP/1.0 Host: api.github.com:443 User-Agent: php-requests/1.6.1 Accept-Encoding: deflate;q=1.0, compress;q=0.5, gzip;q=0.5 Accept: application/json Authorization: Basic dXNlcjpwYXNz Connection: Close
" string(256) "GET /gists HTTP/1.0 Host: api.github.com:443 User-Agent: php-requests/1.6.1 Accept-Encoding: deflate;q=1.0, compress;q=0.5, gzip;q=0.5 Accept: application/json Authorization: Basic dXNlcjpwYXNz Authorization: Basic dXNlcjpwYXNz Connection: Close
"
Note that on the second request, there are two Authorization header. Similarly, for the third request, there will be three Authorization headers added to the request.
This is (somewhat) intentional; the hooks system is per-request. I would like to consider changing that at some point however.
Steps to reproduce - Use the following sript
The result from the above script execution
Note that on the second request, there are two Authorization header. Similarly, for the third request, there will be three Authorization headers added to the request.