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

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

Open
dkmuir opened this issue Jun 28, 2016 · 1 comment

Comments

@dkmuir
Copy link

dkmuir commented Jun 28, 2016

Originally zendframework/zendframework#6101

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

The new host header gets set up in https://github.com/zendframework/zend-http/blob/master/src/Client.php#L1110

But then gets replaced with the header from the request here:
https://github.com/zendframework/zend-http/blob/master/src/Client.php#L1174

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

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas/laminas-http; a new issue has been opened at laminas/laminas-http#19.

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

No branches or pull requests

2 participants