@@ -27,6 +27,7 @@ class MockResponse implements ResponseInterface
27
27
use ResponseTrait;
28
28
29
29
private $ body ;
30
+ private $ requestOptions = [];
30
31
31
32
private static $ mainMulti ;
32
33
private static $ idSequence = 0 ;
@@ -42,6 +43,28 @@ public function __construct($body = '', array $info = [])
42
43
{
43
44
$ this ->body = \is_iterable ($ body ) ? $ body : (string ) $ body ;
44
45
$ 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 ;
45
68
}
46
69
47
70
/**
@@ -66,6 +89,7 @@ protected function close(): void
66
89
public static function fromRequest (string $ method , string $ url , array $ options , ResponseInterface $ mock ): self
67
90
{
68
91
$ response = new self ([]);
92
+ $ response ->requestOptions = $ options ;
69
93
$ response ->id = ++self ::$ idSequence ;
70
94
$ response ->content = ($ options ['buffer ' ] ?? true ) ? fopen ('php://temp ' , 'w+ ' ) : null ;
71
95
$ response ->initializer = static function (self $ response ) {
0 commit comments