On Sat, 11 Apr 2015, Dan Book wrote:

> Perhaps this way:
> my $tx = $ua->build_tx($method => ... normal get/post/etc args ...);
> $ua->start($tx => sub {
>   ...
> });

Thanks. I'll try that.

Next problem is what needs to be done to read the request body and 
transfer it to the ua. Would that happen automatigically if the req is 
cloned? In this case, would Mojo buffer the request? Does anyone have a 
gist which proxies a request without reading and caching the request body?

I've found this which deals with some of these issues:

https://larig.wordpress.com/2012/08/01/a-mini-proxy-via-mojolicious/

Thanks all.

> 
> On Fri, Apr 10, 2015 at 4:01 PM, Charlie Brady <
> [email protected]> wrote:
> 
> >
> > https://github.com/kraih/mojo/wiki/Blocking-vs-non-blocking-101
> >
> > I see I can do this to have a non-blocking get handler:
> >
> > ...
> >   $self->render_later;
> >
> >   $self->ua->get('http://www.superhugepage.com/blah.html' => sub {});
> > ...
> >
> > But I don't understand how to use Mojo::UserAgent in an 'any' handler,
> > where method might be 'get', 'put', 'delete', etc. Do I build a tx, attach
> > the callback to 'finish', then start it? Or just do:
> >
> > $method = $self->req->method;
> > $self->ua->$method()
> >
> > ?
> >
> > Thanks
> >
> 
> 

Reply via email to