Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.
This repository was 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

Description

@dkmuir

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions