File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -132,7 +132,9 @@ public static function fromArray(array $request)
132132 public function setUrl ($ url )
133133 {
134134 $ this ->url = $ url ;
135- $ this ->setHeader ('Host ' , $ this ->getHost ());
135+ if (! array_key_exists ('Host ' , $ this ->headers )) {
136+ $ this ->setHeader ('Host ' , $ this ->getHost ());
137+ }
136138 }
137139
138140 /**
Original file line number Diff line number Diff line change @@ -216,6 +216,22 @@ public function testGetHostReturnsBothHostAndPort()
216216 $ this ->assertEquals ('example.com:5000 ' , $ request ->getHost ());
217217 }
218218
219+ public function testDoNotOverwriteHostHeader ()
220+ {
221+ $ this ->request = new Request (
222+ 'GET ' ,
223+ 'http://example.com ' ,
224+ array ('User-Agent ' => 'Unit-Test ' , 'Host ' => 'www.example.com ' ));
225+
226+ $ this ->assertEquals (
227+ array (
228+ 'User-Agent ' => 'Unit-Test ' ,
229+ 'Host ' => 'www.example.com '
230+ ),
231+ $ this ->request ->getHeaders ()
232+ );
233+ }
234+
219235 public function testCurlCustomRequestOverridesMethod ()
220236 {
221237 $ postRequest = new Request ('POST ' , 'http://example.com ' );
You can’t perform that action at this time.
0 commit comments