hsn22 has asked for the wisdom of the Perl Monks concerning the following question:

for some weird reason i get the following error
Can't locate object method "file" via package "HTTP::Recorder" at prox +y.pl line 13.
my proxy.pl is
use strict; use warnings; use HTTP::Proxy; use HTTP::Recorder; my $proxy = HTTP::Proxy->new(); # create a new HTTP::Recorder object my $agent = new HTTP::Recorder; # set the log file (optional) $agent->file("c:\\file"); # set HTTP::Recorder as the agent for the proxy $proxy->agent( $agent ); # start the proxy $proxy->start(); 1;
im a noob just fallen in love with perl so please exuse me if this seems silly.

Replies are listed 'Best First'.
Re: problem with http::recorder
by tilly (Archbishop) on May 21, 2007 at 07:15 UTC
    Then you have a severely messed up installation of HTTP::Recorder. I would suggest looking at the code for it to see if anything obvious is wrong. (The command perldoc -m HTTP::Recorder should give you the relevant code.) The most obvious thing to look for is whether something is keeping the last =cut before sub file from being read properly by Perl. (The most likely explanation is that someone edited it by hand somehow and messed it up.)

    In the unlikely event that no other explanation is available, if I was to really reach, I'd guess that you have a Windows file that is being read under *nix and a \r\n stops Perl from properly reading an =cut. However I'd be rather surprised if that was the real answer since I've never heard of anyone having bugs like that. Then again I haven't tried to keep track and wouldn't necessarily have heard of such problems if they existed. (I do not personally use Windows and I haven't been very active in the Perl community in recent years.)

Re: problem with http::recorder
by planetscape (Chancellor) on May 21, 2007 at 09:05 UTC

    Are you, by chance, running your proxy.pl under Cygwin? I do, and my proxy.pl looks something like this (note forward vs. back slashes in $agent->file):

    #!/usr/bin/perl use HTTP::Proxy; use HTTP::Recorder; my $proxy = HTTP::Proxy->new(); my $agent = new HTTP::Recorder( showwindow => 1 ); # set the log file (optional) $agent->file("/tmp/myfile"); # set HTTP::Recorder as the agent for the proxy $proxy->agent( $agent ); # start the proxy $proxy->start(); 1;

    BTW, you may also be interested in this thread.

    HTH,

    planetscape
Re: problem with http::recorder
by Khen1950fx (Canon) on May 21, 2007 at 08:41 UTC
    I think that you were on the right track. This worked for me:

    use strict; use warnings; use HTTP::Proxy; use HTTP::Recorder; my $proxy = HTTP::Proxy->new( port => 3128 ); my $agent = new HTTP::Recorder; #Try C:\Desktop\Agent\log $agent->file("/home/Desktop/Agent/log"); $proxy->agent( $agent ); $agent->control(["http://127.0.0.1"]); $proxy->start(); 1;

    Try file with one backslash. I added  control. It won't work without it because http://127.0.0.1 will become the URL for my http-recorder.

    First, create a directory on the desktop---I called it Agent. Then create a file called log.

    Next, after $proxy->start();, minimize the prompt and go to your browser. Manually adjust the browser so that it can use the proxy. Type in http://127.0.0.1, or whatever URL that you want to use. Then start your browsing. After you're finished, check the log in Agent.

    I've tried to keep this clear and simple, but if it's not, then please let me know.

      Hey, U said "Manually adjust the browser so that it can use the proxy." Kinda got stuck there. Could you tell me the proxy settings that I need to add to enable recording ? I don't know my company's proxy.
      Yep, this works until one wants to access HTTPS pages on a web server that is using self signed certificates.
      Have you seen this ?

      LWP::Protocol::https::Socket: SSL connect attempt failed with unknown errorerror:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed at ...lib/LWP/Protocol/http.pm line 51.

      Or, is there an easy setup to ignore certificate checks ??
A reply falls below the community's threshold of quality. You may see it by logging in.