501 Protocol scheme '' is not supported error when using LWP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jovalBag
    New Member
    • Nov 2008
    • 5

    501 Protocol scheme '' is not supported error when using LWP

    hi

    I'm trying to use the example here:


    here is the code:
    Code:
    use LWP::UserAgent;
    use LWP::Debug qw(+); 
    
    	# Create a user agent object
    	my $ua = LWP::UserAgent->new;
    	$ua->agent("MyApp/0.1 ");
    
    	# Create a request
    	my $req = HTTP::Request->new(POST => 'http://search.cpan.org/search');
    	$req->content_type('application/x-www-form-urlencoded');
    	$req->content('query=libwww-perl&mode=dist');
    
    	# Pass request to the user agent and get a response back
    	my $res = $ua->request($req);
    
    	# Check the outcome of the response
    	if ($res->is_success) {
    		print $res->content;
    	} else {
          print $res->status_line, "\n";
    	}
    and here is the response:
    Code:
    LWP::UserAgent::new: ()
    LWP::UserAgent::request: ()
    LWP::UserAgent::send_request: POST http://search.cpan.org/search
    LWP::UserAgent::request: Simple response: Not Implemented
    501 Protocol scheme '' is not supported
    what am I doing wrong? what is the meaning of the error response?
  • RonB
    Recognized Expert Contributor
    • Jun 2009
    • 589

    #2
    Try using a GET request instead of the POST request.

    Comment

    Working...