in reply to Re: Trying to Copy Live Http Replay
in thread Trying to Copy Live Http Replay

Using Wireshark, I found that \r\n is being converted to %5Cr%5Cn ... any thoughts how to stop that from happening?

Replies are listed 'Best First'.
Re^3: Trying to Copy Live Http Replay
by Corion (Patriarch) on Mar 12, 2010 at 17:37 UTC

    Use interpolating strings, or better, don't try to add \r\n yourself, as HTTP::Headers should format your headers anyway.

Re^3: Trying to Copy Live Http Replay
by spazm (Monk) on Mar 12, 2010 at 17:56 UTC
    1) you will definitelypossibly need the cookies. You can either manually add a cookie header with the value listed, or you can use a cookie jar.

    2) Try backing out from using the ua->post method to creating a post from HTTP::Request::Common so you can interact with and examine it.

    3) note that the outgoing request was text/plain. No URL encoding was done.

    Turns out you just need it in the format it wants, and will accept text/plain or x/www-form-encoded content.

    #!/usr/bin/perl use warnings; use strict; use HTTP::Request::Common; use LWP::UserAgent; use Data::Dumper; my %fields = ( "LeagueID" => "9\r\n", "GameDate" => "3-2-2010\r\n", "Season" => "2009-2010\r\n", "Refresh" => "false\r\n", "LastUpdateTime" => "01-01-1900\r\n", "type" => "Matchups\r\n", "RefreshStartTime" => "11-2-2010-1268372427240\r\n", "Week" => "\r\n", "conferenceID" => "", ); my $robot = LWP::UserAgent->new; use HTTP::Request::Common; my $url = 'http://scores.covers.com/ajax/SportsDirect.Controls.LiveScoresC +ontrols.Scoreboard,SportsDirect.Controls.LiveScoresControls.ashx?_met +hod=UpdateScoreboard&_session=no'; my $post = POST $url , \%fields; # $post would be url-encoded # 'content-type' => 'application/x-www-form-urlencoded', # print Dumper $post; my $content = qq{LeagueID=9\r\nGameDate=3-2-2010\r\nSeason=2009-2010\r +\nRefresh=true\r\nLastUpdateTime=01-01-1900\r\ntype=Matchups\r\nRefre +shStartTime=12-2-2010-1268408433293\r\nWeek=\r\nconferenceID=}; # your target url appears to accept either of these my $post2 = POST $url, Content => $content; #my $post2 = POST $url, 'content-type' => 'text/plain', Content => $co +ntent; print Dumper $post2; print Dumper $robot->request( $post2);
    at least I assume this is the sort of output you were expecting:
    '_content' => '{\'LeagueID\':9,\'League\':\'NBA\',\'GameDate\':\'3-2- +2010\',\'Season\':\'2009-2010\',\'Week\':\'\',\'GameResponseList\':[] +,\'LastUpdateTime\':\'01-01-1900\',\'RefreshStartTime\':\'12-2-2010-1 +268408433293\',\'Refresh\':true,\'PageType\':\'Matchups\',\'ScoreBoar +dHTML\':\'<div id="Scoreboard_9"><table class="scoreboard" border="0" +>\\r\\n <tr>\\r\\n <td class="scoreboard-left"><div + id="Game_9_781166" class="game-box"><span class="activetab" id="In_G +ame_Status_9_781166">Final</span><div class="soright" id="Title_9_781 +166">Boston at Detroit</div><span class="pick_button"><a href="http:/ +/contests.covers.com/sportscontests/makepicks.aspx?sportID=9&EventID= +781166"><img src="http://images.covers.com/scores/general/pick.gif" a +lign="absmiddle" alt="contest pick" border="0"
      I was so close! I had gotten to the same idea, but was wrapping '' around the content instead of qq{}! Thanks so much!
        using "" and qq{} should be nearly equivalent(1). In both cases you need to be careful to not include additional whitespace.

        Here are four equivalent declarations using "" and qq{}.

        #/usr/bin/perl use strict; use warnings; use Test::More tests =>4 ; my $a1 = qq{a\r\nb\r\nc\r\n}; my $a2 = qq{a\r b\r c\r }; my $b1 = "a\r\nb\r\nc\r\n"; my $b2 = "a\r b\r c\r\n"; is( $a1, $a2, "a1 and a2 are the same"); is( $b1, $b2, "b1 and b2 are the same"); is( $a1, $b1, "a1 and b1 are the same"); is( $a2, $b2, "a2 and b2 are the same"); __END__ 1..4 ok 1 - a1 and a2 are the same ok 2 - b1 and b2 are the same ok 3 - a1 and b1 are the same ok 4 - a2 and b2 are the same

        1 -- except for the semantics used for escaping, qq will escape double-quotes in the string.