I did a quick benchmark, and I'm fairly satisfied it's not a performance concern (in recent versions of PHP) for normal use-cases.
https://bitbucket.org/mindplaydk/header-bench/src/master/ I still think the code to manually copy headers is ugly and verbose, but, well... may be one of those cases where ugly and verbose makes sense... On Mon, Nov 12, 2018 at 6:27 PM Larry Garfield <la...@garfieldtech.com> wrote: > On Monday, November 12, 2018 7:37:03 AM CST Stefano Torresi wrote: > > > Like, why doesn't it have a withHeaders() method that lets you > > > apply/replace all the headers? > > > > I guess because what that would do in every implementation is calling > > `withHeader` in a loop. :-P > > > > Is this really that big of a problem? OTOH the message interface is > already > > quite crowded. > > > > Also, a very lengthy discussion could be made on how the `$headers` input > > array should or shouldn't be structured. > > Matthew and I talked about that during the PSR-7 development. It was one > of > the confusion points I had in my own implementation attempts. > Specifically, > is withHeaders() "replace all headers and have just these" or is it > "multi-add > these headers, as if you were looping"? Or "multi-add but replace > existing > headers if the name already exists, which is different behavior than a > loop on > addHeader()"? > > It was just too confusing, so since a loop on withHeader() is so cheap the > decision was to go for the smaller, more self-documenting surface area. > > --Larry Garfield > > -- > You received this message because you are subscribed to a topic in the > Google Groups "PHP Framework Interoperability Group" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/php-fig/aMetK_LAmsk/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > php-fig+unsubscr...@googlegroups.com. > To post to this group, send email to php-fig@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/php-fig/1711626.aciqfvl2hO%40vulcan. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+unsubscr...@googlegroups.com. To post to this group, send email to php-fig@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/CADqTB_hSw6%2B-ZscxfDSOSAcsgNKAwmbny9JC36bsKrKaKr8uXg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.