Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Request object can't easily be proxied because new headers get overwritten by original request's headers #6101

Closed
dkmuir opened this issue Apr 8, 2014 · 1 comment

Comments

@dkmuir
Copy link

dkmuir commented Apr 8, 2014

I have an action that proxies the current request by modifying the Uri in the original request and then sending it through Zend\Http\Client. However, the new Host header based on the Uri gets overwritten by the original Host header in the original request.

Eg:

//original uri: http://example.com/proxy-request
$request = clone $this->request;
$uri = $request->getUri();
$uri->setHost('target-site.com');
$uri->setPath('/proxy-target');

$client = new Zend\Http\Client();
$response = $client->send($request);

The request ends up being sent to http://example.com/proxy-target instead of http://target-site.com/proxy-target

This is because of the lines here:
https://github.com/zendframework/zf2/blob/master/library/Zend/Http/Client.php#L1156

Shouldn't the new headers take precedence over the headers from the request?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants