sergot / http-useragent

Web user agent class for Perl 6.
MIT License
36 stars 39 forks source link

Order of received headers not preserved #201

Open zoffixznet opened 6 years ago

zoffixznet commented 6 years ago

All the headers are being passed around in a Hash, which doesn't keep around the order in which the items were added. Rakudo implementation used to preserve the order as a limitation of hash implementation, which has been recently fixed. There are tests in the test suite that rely on the buggy, non-randomized order and they're now failing (https://github.com/sergot/http-useragent/issues/197 https://github.com/sergot/http-useragent/issues/199 https://github.com/sergot/http-useragent/pull/200)

While RFC 2616, section 4.2 says order of headers with different names doesn't matter, it's been suggested it should be preserved as some tools base their decisions based on the order.

Looking at the code, the problem is actually in the module itself and not the tests. The HTTP::Header.new, HTTP::Header.init-field, and HTTP::Response.new take headers via a Hash, and would need to be redesigned to include a multi that accepts an ordered list of headers.

Given the popularity of this module, in the meantime, I suggest the failing tests would be fudged to fix failures in installations and automated testing of all the modules that use this one.