in reply to Re: LWP: transfer from Python to Perl
in thread LWP: transfer from Python to Perl

In the perl version the server response with an Error 500 Internal Server Error.

Without further details the best guess would be that you have not set the Content-Type header correctly (or at all). It also looks like you are attempting to set headers with leading underscores in the key. That's not going to work either.

Can I log what was exactly sent

Listen on the wire; see tcpdump for that. Otherwise use $request->dump.

Replies are listed 'Best First'.
Re^3: LWP: transfer from Python to Perl
by Anonymous Monk on Jan 10, 2018 at 17:34 UTC
    Hi hippo,

    Sorry for these basic questions. Thats one of my first web programs. I logged the packet:. I see some differences, but I can not really charge if this can be the rootcause: (first good one, second problem one)
    Accept-Encoding: identity Content-Type: application/x-www-form-urlencoded Content-Length: 2 User-Agent: Python-urllib/3.6 __Atts: 2018 __Ath: FnD= __Atcrv: 88 Connection: close TE: deflate,gzip;q=0.3 Connection: TE, close User-Agent: libwww-perl/6.26 __atcrv: 88 __ath: FnD= __atts: 2018 Content-Length: 2

      This confirms what I suspected in my previous post - namely that you have not set the Content-Type header. Most web servers will depend on this to be set correctly in the requests they receive.

        Thanks hippo

        I added $request->content_type('application/x-www-form-urlencoded'); and some other minor things, but still error 500. The only difference (what I can see now) is now:

        User-Agent: Python-urllib/3.6 Connection: close TE: deflate,gzip;q=0.3 Connection: close,TE User-Agent: libwww-perl/6.26
        Can this be the reason? How can I influence TE and Connection ? I added

        ${${$request}{'_headers'}}{'Connection'}='close';</p><p>
        but than Connection changed from :

        Connection: TE,close to Connection: close,TE
Re^3: LWP: transfer from Python to Perl
by Anonymous Monk on Jan 10, 2018 at 16:00 UTC
    For the header key I saw also when I Dumper($request) the '_' were changed to '-'. (use Data::Dumper qw(Dumper); ) So I tried to write the header directly in the request structure.
    ${${$request}{'_headers'}}{'__atts'}=$ajax_atts; ${${$request}{'_headers'}}{'__ath'}=$ajax_ath; ${${$request}{'_headers'}}{'__atcrv'}=$ajax_atcrv2; print Dumper($request)
    Now the '_' are unchanged, but still error 500.

      You can preserve the underscores with a colon

      $request->header( ':__Atts' => $ajax_atts, ':__Ath' => $ajax_ath, ':__Atcrv'=> $ajax_atcrv);

      see NON-CANONICALIZED FIELD NAMES in HTTP::Headers

      poj