18
18
use CodeIgniter \Format \JSONFormatter ;
19
19
use CodeIgniter \Format \XMLFormatter ;
20
20
use CodeIgniter \HTTP \DownloadResponse ;
21
+ use CodeIgniter \HTTP \Header ;
21
22
use CodeIgniter \HTTP \IncomingRequest ;
22
23
use CodeIgniter \HTTP \RequestInterface ;
23
24
use CodeIgniter \HTTP \ResponseInterface ;
@@ -140,8 +141,16 @@ public function run(float $startTime, float $totalTime, RequestInterface $reques
140
141
$ data ['vars ' ]['post ' ][esc ($ name )] = is_array ($ value ) ? '<pre> ' . esc (print_r ($ value , true )) . '</pre> ' : esc ($ value );
141
142
}
142
143
143
- foreach ($ request ->headers () as $ header ) {
144
- $ data ['vars ' ]['headers ' ][esc ($ header ->getName ())] = esc ($ header ->getValueLine ());
144
+ foreach ($ request ->headers () as $ name => $ value ) {
145
+ if ($ value instanceof Header) {
146
+ $ data ['vars ' ]['headers ' ][esc ($ name )] = esc ($ value ->getValueLine ());
147
+ } else {
148
+ foreach ($ value as $ i => $ header ) {
149
+ $ data ['vars ' ]['headers ' ][esc ($ name )] ??= '' ;
150
+ $ data ['vars ' ]['headers ' ][esc ($ name )] .= ' ( ' . $ i + 1 . ') '
151
+ . esc ($ header ->getValueLine ());
152
+ }
153
+ }
145
154
}
146
155
147
156
foreach ($ request ->getCookie () as $ name => $ value ) {
@@ -157,8 +166,16 @@ public function run(float $startTime, float $totalTime, RequestInterface $reques
157
166
'headers ' => [],
158
167
];
159
168
160
- foreach ($ response ->headers () as $ header ) {
161
- $ data ['vars ' ]['response ' ]['headers ' ][esc ($ header ->getName ())] = esc ($ header ->getValueLine ());
169
+ foreach ($ response ->headers () as $ name => $ value ) {
170
+ if ($ value instanceof Header) {
171
+ $ data ['vars ' ]['response ' ]['headers ' ][esc ($ name )] = esc ($ value ->getValueLine ());
172
+ } else {
173
+ foreach ($ value as $ i => $ header ) {
174
+ $ data ['vars ' ]['response ' ]['headers ' ][esc ($ name )] ??= '' ;
175
+ $ data ['vars ' ]['response ' ]['headers ' ][esc ($ name )] .= ' ( ' . $ i + 1 . ') '
176
+ . esc ($ header ->getValueLine ());
177
+ }
178
+ }
162
179
}
163
180
164
181
$ data ['config ' ] = Config::display ();
0 commit comments