user agent & capture groups

26 views
Skip to first unread message

rasta

unread,
Aug 22, 2018, 8:05:41 AM8/22/18
to Mojolicious
Hi Guys!

Using Mojolicious 7.93 I face a rather mysterious issue:

In my app I call 

my $upload = $c->req->upload('file');
my $ua = Mojo::UserAgent->new;
my $post = $ua->post($url => \%headers => form => { file => { file => $upload->asset }} );

where $upload->asset is a Mojo::Asset::Memory in my case.

So far so good, Mojolicious makes the post and sends headers a la

   Mojolicious (Perl)
    multipart
/mixed; boundary=S3ylX
   
Accept-Encoding: gzip
   
1201
(captured through tcpdump)

At some point, I added a check on some data before posting, using a match

if( $data =~ m/(\w+)\/(\w+)/)...

Suddenly, what came out of Mojolicious was

    Mojolicious (Perl)
    n
; boundary=jthCXf
   
Accept-Encoding: gzip
   
1201

Not only 'multipart/mixed' is replaced with 'n', the boundary is actually wrong too.

In the end I found out it happens because of the capture groups in the match. If I don't use them

if( $data =~ m/\w+\/\w+/)...

all is fine again.

Is it possible that Mojolicious uses $1 etc somewhere inside the UserAgent to manipulate headers without calling a match first?

Cheers,
Rasta

sri

unread,
Aug 22, 2018, 9:56:11 AM8/22/18
to Mojolicious
If you can make a script replicating the problem please open an issue on GitHub and report it as a bug.

--
sebastian

Rastislav Hudak

unread,
Aug 23, 2018, 4:26:41 AM8/23/18
to mojol...@googlegroups.com
Ok, thanks sebastian, here it is: https://github.com/kraih/mojo/issues/1253


--
You received this message because you are subscribed to a topic in the Google Groups "Mojolicious" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mojolicious/SsqdpiTy_3w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mojolicious...@googlegroups.com.
To post to this group, send email to mojol...@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Rastislav Hudak

unread,
Aug 23, 2018, 4:28:00 AM8/23/18
to mojol...@googlegroups.com
Oh wait, I did a mistake

Rastislav Hudak

unread,
Aug 23, 2018, 4:30:59 AM8/23/18
to mojol...@googlegroups.com
Ok, I've fixed the example ;)
Reply all
Reply to author
Forward
0 new messages