raku-community-modules / LWP-Simple

LWP::Simple quick & dirty implementation for Rakudo
http://www.streppone.it/cosimo/blog/tag/LWP::Simple/
Artistic License 2.0
7 stars 9 forks source link

Content-Type check not case insensitive #22

Closed wbiker closed 5 years ago

wbiker commented 6 years ago

Hi all,

I want use LWP::Simple to send data to elasticsearch. This works, however the response is always given back by LWP::Simple as Buffer. I dived in the code and found the problem and kind of fixed it. The problem is:

elsif (not $.force_no_encode) && $resp_headers<Content-Type> &&
                $resp_headers<Content-Type> ~~

Changing the hash key names to content-type fixes my problem. Creating a test and pull request the changes is not that problem. However, I do not know if there are any side effects. Is content-type always lowercase as in the response from elasticsearch. Or could it be both?

Anyone an idea what the standard here says? Or change all hash keys to lowercase first? Thanks, Wolf

stmuk commented 6 years ago

HTTP header names should be case insensitive.

https://tools.ietf.org/html/rfc7230#section-3.2

A patch is welcome.

S

On 16 January 2018 at 18:13, Wolf notifications@github.com wrote:

Hi all,

I want use LWP::Simple to send data to elasticsearch. This works, however the response is always given back by LWP::Simple as Buffer. I dived in the code and found the problem and kind of fixed it. The problem is:

elsif (not $.force_no_encode) && $resp_headers && $resp_headers ~~

Changing the hash key names to content-type fixes my problem. Creating a test and pull request the changes is not that problem. However, I do not know if there are any side effects. Is content-type always lowercase as in the response from elasticsearch. Or could it be both?

Anyone an idea what the standard here says? Or change all has key to lowercase first? Thanks, Wolf

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/perl6/perl6-lwp-simple/issues/22, or mute the thread https://github.com/notifications/unsubscribe-auth/AEUuY1dSRkJ9XKhkQuUGdukfwmz2AXTYks5tLObJgaJpZM4RgNLF .

-- 4096R/EA75174B Steve Mynott steve.mynott@gmail.com

JJ commented 5 years ago

This has been fixed in eb43079ba4c4124fcf7a77bc92dabce1d0d5b2d5 Can you please check and, if that's so, close the issue?