Skip Menu |

This queue is for tickets about the AnyEvent-HTTP-Message CPAN distribution.

Report information
The Basics
Id: 80501
Status: open
Priority: 0/
Queue: AnyEvent-HTTP-Message

People
Owner: Nobody in particular
Requestors: pagenyon [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Possibly causes mangling of request
schmorp on AnyEvent irc channel suggested i report this bug here. I'm trying to POST with AnyEvent::HTTP::Request using an HTTP::Request constructed from another module, but the request that gets sent on the wire is mangled. I initially posted this question on perlmonks: http://www.perlmonks.org/?node_id=1001399 . I have attached a script to demonstrate the issue.
Subject: ae-httpreq.pl
#!/usr/bin/env perl use 5.014; use warnings; use Data::Dump; BEGIN { package Local::Finance::MtGox; use parent 'Finance::MtGox'; # Don't post to th real mtgox server, post to a site that displays the # request. sub _build_api_method_uri { return URI->new("http://h.wrttn.me/post"); } } use AnyEvent; use AnyEvent::HTTP::Request; use AnyEvent::HTTP::Response; my $mtgox = Local::Finance::MtGox->new({ key => 'key', secret => 'secret' }); my $cv = AE::cv; my $req = AnyEvent::HTTP::Request->new( # Returns an HTTP::Request $mtgox->_build_api_method_request(POST => 'getFunds'), { cb => sub { my $res = AnyEvent::HTTP::Response->new(@_)->to_http_message; dd $res; $cv->send; }, params => { tls_ctx => 'low', # Debugging with Charles proxy. # proxy => ['127.0.0.1', 8888], }, } ); $req->send; $cv->wait;
From: pagenyon [...] gmail.com
On Tue Oct 30 16:10:45 2012, pagenyon wrote: Show quoted text
> schmorp on AnyEvent irc channel suggested i report this bug here. I'm > trying to POST with AnyEvent::HTTP::Request using an HTTP::Request > constructed from another module, but the request that gets sent on the > wire is mangled. I initially posted this question on perlmonks: > http://www.perlmonks.org/?node_id=1001399 . > I have attached a script to demonstrate the issue.
So this looks like the base64-encoded value contains embedded newlines, which HTTP::Headers can handle fine, so maybe AnyEvent::Message should be using that. It should also probably also add the Content-Type like HTTP::Request::Common.
From: pagenyon [...] gmail.com
On Sat Nov 03 07:53:19 2012, pagenyon wrote: Show quoted text
> On Tue Oct 30 16:10:45 2012, pagenyon wrote:
> > schmorp on AnyEvent irc channel suggested i report this bug here. I'm > > trying to POST with AnyEvent::HTTP::Request using an HTTP::Request > > constructed from another module, but the request that gets sent on the > > wire is mangled. I initially posted this question on perlmonks: > > http://www.perlmonks.org/?node_id=1001399 . > > I have attached a script to demonstrate the issue.
> > So this looks like the base64-encoded value contains embedded newlines, > which HTTP::Headers can handle fine, so maybe AnyEvent::Message should > be using that. It should also probably also add the Content-Type like > HTTP::Request::Common.
I take that back. It looks like the newlines in headers are stripped in LWP::Protocol::http.
Thanks for the report. I'm glad you figured out the issue. Definitely the originating module is the appropriate place to fix that (I saw the bug you filed against Finance::MtGox). I think I will add something to check for that here as well (much like the protocol module does) because why bother to submit an http request if you know it won't possibly work. There is in fact a line in the AnyEvent::HTTP docs that says "make sure that your headers names and values do not contain any embedded newlines". So I just need to decide the appropriate place for it.