1818use CodeIgniter \Format \JSONFormatter ;
1919use CodeIgniter \Format \XMLFormatter ;
2020use CodeIgniter \HTTP \DownloadResponse ;
21+ use CodeIgniter \HTTP \Header ;
2122use CodeIgniter \HTTP \IncomingRequest ;
2223use CodeIgniter \HTTP \RequestInterface ;
2324use CodeIgniter \HTTP \ResponseInterface ;
@@ -140,8 +141,16 @@ public function run(float $startTime, float $totalTime, RequestInterface $reques
140141 $ data ['vars ' ]['post ' ][esc ($ name )] = is_array ($ value ) ? '<pre> ' . esc (print_r ($ value , true )) . '</pre> ' : esc ($ value );
141142 }
142143
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+ }
145154 }
146155
147156 foreach ($ request ->getCookie () as $ name => $ value ) {
@@ -157,8 +166,16 @@ public function run(float $startTime, float $totalTime, RequestInterface $reques
157166 'headers ' => [],
158167 ];
159168
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+ }
162179 }
163180
164181 $ data ['config ' ] = Config::display ();
0 commit comments