laminas / laminas-http

Provides an easy interface for performing Hyper-Text Transfer Protocol (HTTP) requests
https://docs.laminas.dev/laminas-http/
BSD 3-Clause "New" or "Revised" License
36 stars 27 forks source link

`Headers#toArray` does not properly return all header values #60

Closed boesing closed 2 years ago

boesing commented 2 years ago
Q A
Bugfix yes
BC Break no

Description

When working on a project in combination with the laminas/laminas-psr7bridge and laminas/laminas-diactoros, we ran into a bug where the Headers#toArray method iterated over its (not initialized) headers and thus extended the array which is currently iterated within Headers#lazyLoadHeader: https://github.com/laminas/laminas-http/blob/e1f3420ab35e21ea135913d213b8d570e5e7b513/src/Headers.php#L507

Not sure if this ever worked properly tho. Maybe another problem is that Set-Cookie is merged into a single value in https://github.com/laminas/laminas-psr7bridge/blob/a560f42d66fc11b0b05e7d2103e69e434365e7c1/src/Psr7Response.php#L80 as well but as of now, extending an iterator while its being iterated simply won't work for an array and thus, I've rewritten the way how Headers#toArray works by enforcing the lazy conversion before iterating over the headers.

boesing commented 2 years ago

Fixed 8.1 php-fpm issues in #62