in reply to Changing WWW::Mechanize Request to obey ModSecurity rules

Mechanize wants to send something like this:

Wants to send or actually did send. What's in the HTTP::Request isn't what gets sent. You need to listen to the wire to see what's actually set. You didn't specify what version of LWP you are using, but the latest one claims to use HTTP/1.1 by default (which will use the Host header as in your second snippet).

  • Comment on Re: Changing WWW::Mechanize Request to obey ModSecurity rules

Replies are listed 'Best First'.
Re^2: Changing WWW::Mechanize Request to obey ModSecurity rules
by pdc (Initiate) on Feb 26, 2009 at 14:15 UTC

    I was basing it on something like this:

    my $response = $mech->get($location); print "REQUEST: \n" . $response->request->as_string ." --REQUEST\n";
    It looks like you're right about it being different, which makes things a bit more difficult.

    Normally I'd use wireshark to look at this, but I'm not really a network admin and I'm not sure if there's a way to look directly at the wire and decrypt the SSL content.

      Create a little program that creates a server socket, accepts a connection, and dumps the incoming data. Connect to that instead of a real HTTP server.
        Here you go, shows everything is as it should be :)
        #!/usr/bin/perl -- use strict; use warnings; use IO::Socket; my $sock = IO::Socket::INET->new ( Localhost => 'localhost', LocalPort => '18080', Proto => 'tcp', Listen => 1, ); die "cant do that: $!\n" unless $sock; print "Please contact me at: http://localhost:18080\n"; my $CRLF = "\015\012"; while(my $s = $sock->accept()){ while(<$s>){ print $s "Echo: $_"; last if /^\s+$/; } close $s; } close $sock; __END__ $ lwp-request http://localhost:18080 Echo: GET / HTTP/1.1 Echo: TE: deflate,gzip;q=0.3 Echo: Connection: TE, close Echo: Host: localhost:18080 Echo: User-Agent: lwp-request/2.06 Echo: