@@ -27,6 +27,7 @@ class MockResponse implements ResponseInterface
2727 use ResponseTrait;
2828
2929 private $ body ;
30+ private $ requestOptions = [];
3031
3132 private static $ mainMulti ;
3233 private static $ idSequence = 0 ;
@@ -42,6 +43,28 @@ public function __construct($body = '', array $info = [])
4243 {
4344 $ this ->body = \is_iterable ($ body ) ? $ body : (string ) $ body ;
4445 $ this ->info = $ info + $ this ->info ;
46+
47+ if (!isset ($ info ['raw_headers ' ])) {
48+ return ;
49+ }
50+
51+ $ rawHeaders = [];
52+
53+ foreach ($ info ['raw_headers ' ] as $ k => $ v ) {
54+ foreach ((array ) $ v as $ v ) {
55+ $ rawHeaders [] = (\is_string ($ k ) ? $ k .': ' : '' ).$ v ;
56+ }
57+ }
58+
59+ $ info ['raw_headers ' ] = $ rawHeaders ;
60+ }
61+
62+ /**
63+ * Returns the options used when doing the request.
64+ */
65+ public function getRequestOptions (): array
66+ {
67+ return $ this ->requestOptions ;
4568 }
4669
4770 /**
@@ -66,6 +89,7 @@ protected function close(): void
6689 public static function fromRequest (string $ method , string $ url , array $ options , ResponseInterface $ mock ): self
6790 {
6891 $ response = new self ([]);
92+ $ response ->requestOptions = $ options ;
6993 $ response ->id = ++self ::$ idSequence ;
7094 $ response ->content = ($ options ['buffer ' ] ?? true ) ? fopen ('php://temp ' , 'w+ ' ) : null ;
7195 $ response ->initializer = static function (self $ response ) {
0 commit comments