I had quite a bit of success recently using Mojo::UserAgent so I tried to
replace a curl command to do a backup of my Fritz.box router with M::U.
Here is the curl command:
curl -s -k -o $OUT --form sid=$SID --form ImportExportPassword=$BAKPWD \
--form ConfigExport= http://fritz.box/cgi-bin/firmwarecfg
It should be equivalent to this M::U request:
my $tx = $ua->build_tx(
POST => 'http://fritz.box/cgi-bin/firmwarecfg' =>
{
'Accept' => '*/*',
'Content-Type' => 'multipart/form-data',
} => form => {
sid => $SID,
ImportExportPassword => $BAKPWD,
ConfigExport => '',
}
);
# for debugging:
print $tx->req->to_string;
$tx = $ua->start($tx);
$tx->res->save_to($OUT);
As far as I can tell both the headers and the POST body is very much the
same (except the boundary value to separate the form fields) but to my
surprise the curl command works ($OUT is the backup file) but with the M::U
version $OUT consists of some HTML output indicating an error.
If I could see a difference I could try to better adjust my script but as I
said, they look very much the same (I compared it with the -v and
--trace-ascii output of curl), so I run out of ideas what could trigger the
differnt response of my Fritz.box.
Any ideas? At the moment I just solve it by using the curl command with
"system" but I would prefer a Perl-only solution and what is even more
important to me: I want to understand what is going on here.
-Michael
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/mojolicious/14df452c-e7a4-4b7c-90a2-9e1f5e15becc%40googlegroups.com.