develooper Front page | perl.libwww | Postings from December 2001

Re: HEAD https://foo/ and 'not supported'

Thread Previous | Thread Next
From:
Gisle Aas
Date:
December 11, 2001 13:13
Subject:
Re: HEAD https://foo/ and 'not supported'
Message ID:
lr4rmxqx5j.fsf@caliper.activestate.com
Rodent of Unusual Size <Ken.Coar@Golux.Com> writes:

> When I try the (LWP 5.62) HEAD shortcut against an SSL site:
> 
>   HEAD https://foohost/
> 
> I get '501 Protocol scheme 'https' is not supported'.  If I do

This works when you have installed some SSL module, like Crypt-SSLeay.

>   HEAD -SsUe https://foohost/
> 
> I get "Can't call method "url" on an undefined value at
> /path/HEAD line 415."

This is a bug.  This is a fix:

Index: lib/LWP/UserAgent.pm
===================================================================
RCS file: /cvsroot/libwww-perl/lwp5/lib/LWP/UserAgent.pm,v
retrieving revision 2.0
retrieving revision 2.1
diff -u -r2.0 -r2.1
--- lib/LWP/UserAgent.pm	2001/11/19 16:55:54	2.0
+++ lib/LWP/UserAgent.pm	2001/12/11 21:11:29	2.1
@@ -1,4 +1,4 @@
-# $Id: UserAgent.pm,v 2.0 2001/11/19 16:55:54 gisle Exp $
+# $Id: UserAgent.pm,v 2.1 2001/12/11 21:11:29 gisle Exp $
 
 package LWP::UserAgent;
 use strict;
@@ -103,7 +103,7 @@
 
 require LWP::MemberMixin;
 @ISA = qw(LWP::MemberMixin);
-$VERSION = sprintf("%d.%03d", q$Revision: 2.0 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%03d", q$Revision: 2.1 $ =~ /(\d+)\.(\d+)/);
 
 use HTTP::Request ();
 use HTTP::Response ();
@@ -284,11 +284,11 @@
     local($SIG{__DIE__});  # protect agains user defined die handlers
 
     # Check that we have a METHOD and a URL first
-    return HTTP::Response->new(&HTTP::Status::RC_BAD_REQUEST, "Method missing")
+    return _new_response($request, &HTTP::Status::RC_BAD_REQUEST, "Method missing")
 	unless $method;
-    return HTTP::Response->new(&HTTP::Status::RC_BAD_REQUEST, "URL missing")
+    return _new_response($request, &HTTP::Status::RC_BAD_REQUEST, "URL missing")
 	unless $url;
-    return HTTP::Response->new(&HTTP::Status::RC_BAD_REQUEST, "URL must be absolute")
+    return _new_response($request, &HTTP::Status::RC_BAD_REQUEST, "URL must be absolute")
 	unless $url->scheme;
 
     LWP::Debug::trace("$method $url");
@@ -332,8 +332,7 @@
       $protocol = eval { LWP::Protocol::create($scheme, $self) };
       if ($@) {
 	$@ =~ s/ at .* line \d+.*//s;  # remove file/line number
-
-	return HTTP::Response->new(&HTTP::Status::RC_NOT_IMPLEMENTED, $@);
+	return _new_response($request, &HTTP::Status::RC_NOT_IMPLEMENTED, $@);
       }
     }
 
@@ -1123,6 +1122,14 @@
     }
     LWP::Debug::debug('Not proxied');
     undef;
+}
+
+sub _new_response {
+    my($request, $code, $message) = @_;
+    my $response = HTTP::Response->new($code, $message);
+    $response->request($request);
+    $response->header("Client-Date" => HTTP::Date::time2str(time));
+    return $response;
 }
 
 1;


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About