File tree Expand file tree Collapse file tree 4 files changed +44
-1
lines changed
tests/Unit/Common/Http/Uri Expand file tree Collapse file tree 4 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,13 @@ public function retrieveResponse(
43
43
$ extraHeaders ['Content-type ' ] = 'Content-type: application/x-www-form-urlencoded ' ;
44
44
}
45
45
46
- $ extraHeaders ['Host ' ] = 'Host: ' .$ endpoint ->getHost ();
46
+ $ host = 'Host: ' .$ endpoint ->getHost ();
47
+ // Append port to Host if it has been specified
48
+ if ($ endpoint ->hasExplicitPortSpecified ()) {
49
+ $ host .= ': ' .$ endpoint ->getPort ();
50
+ }
51
+
52
+ $ extraHeaders ['Host ' ] = $ host ;
47
53
$ extraHeaders ['Connection ' ] = 'Connection: close ' ;
48
54
49
55
if (is_array ($ requestBody )) {
Original file line number Diff line number Diff line change @@ -397,4 +397,12 @@ public function hasExplicitTrailingHostSlash()
397
397
{
398
398
return $ this ->explicitTrailingHostSlash ;
399
399
}
400
+
401
+ /**
402
+ * @return bool
403
+ */
404
+ public function hasExplicitPortSpecified ()
405
+ {
406
+ return $ this ->explicitPortSpecified ;
407
+ }
400
408
}
Original file line number Diff line number Diff line change @@ -125,4 +125,9 @@ public function getRelativeUri();
125
125
* @return bool
126
126
*/
127
127
public function hasExplicitTrailingHostSlash ();
128
+
129
+ /**
130
+ * @return bool
131
+ */
132
+ public function hasExplicitPortSpecified ();
128
133
}
Original file line number Diff line number Diff line change @@ -871,4 +871,28 @@ public function testHasExplicitTrailingHostSlashFalse()
871
871
872
872
$ this ->assertFalse ($ uri ->hasExplicitTrailingHostSlash ());
873
873
}
874
+
875
+ /**
876
+ * @covers OAuth\Common\Http\Uri\Uri::__construct
877
+ * @covers OAuth\Common\Http\Uri\Uri::parseUri
878
+ * @covers OAuth\Common\Http\Uri\Uri::hasExplicitPortSpecified
879
+ */
880
+ public function testHasExplicitPortSpecifiedTrue ()
881
+ {
882
+ $ uri = new Uri ('http://example.com:8080 ' );
883
+
884
+ $ this ->assertTrue ($ uri ->hasExplicitPortSpecified ());
885
+ }
886
+
887
+ /**
888
+ * @covers OAuth\Common\Http\Uri\Uri::__construct
889
+ * @covers OAuth\Common\Http\Uri\Uri::parseUri
890
+ * @covers OAuth\Common\Http\Uri\Uri::hasExplicitPortSpecified
891
+ */
892
+ public function testHasExplicitPortSpecifiedFalse ()
893
+ {
894
+ $ uri = new Uri ('http://example.com ' );
895
+
896
+ $ this ->assertFalse ($ uri ->hasExplicitPortSpecified ());
897
+ }
874
898
}
You can’t perform that action at this time.
0 commit comments