It's possible the `-k` option to curl is the difference. The equivalent in Mojo::UserAgent is `$ua->insecure(1)` (which you can chain off of).
Scott On Wednesday, May 13, 2020 at 3:56:26 PM UTC-6, Michael Lackhoff wrote: > > 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 mojolicious+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/mojolicious/61ee3b8a-ca87-424d-91e1-f807001afa37%40googlegroups.com.