chansen / p5-http-tiny

Tiny HTTP Client
https://metacpan.org/dist/HTTP-Tiny
53 stars 52 forks source link

Allow manual setting of “Host” header? #78

Closed FGasper closed 8 years ago

FGasper commented 8 years ago

For debugging purposes it would be very handy to be able to set the “Host” header, e.g.:

perl -MYAML::Syck -MHTTP::Tiny-e'my $h = HTTP::Tiny->new(); print Dump( $h->get( "http://localhost/D37ACEE71582AF2D80F9AECCC2531149.txt", { headers => { Host => "abcde.com" } } ) )'

I get why this is actively blocked in the module, but should it not be assumed that a caller that sets “Host” has a good reason to do so?

xdg commented 8 years ago

The spec requires the Host field to match the authority, so this isn't something we allow.

FGasper commented 8 years ago

@xdg I understand that; however, setting a Host header is useful for debugging.

xdg commented 8 years ago

Could you explain your use case more fully? Note there is now a peer option (in the 0.057-TRIAL) that can let you send a request to an arbitrary IP; that keeps the URI and Host in sync while allowing the request to go to, say, localhost. Does that achieve what you need?

FGasper commented 8 years ago

@xdg Yes, I think peer

FGasper commented 8 years ago

… will do the trick. :) 👍

xdg commented 8 years ago

Great!