WordPress / WordPress/Requests
When using the hook system, multiple auth hooks are dispatched, and hence creates multiple auth headers
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.6k
- Forks
- 500
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 5
Description
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"
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the reproduction script with Requests_Hooks, Requests::get, and the fsockopen.before_send hook, then trace how authentication headers are added across successive requests. Done means repeated requests using the same options produce only one Authorization header each.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api, authentication, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100