Re: LWP .01
Joel Scotkin (scotkin_joel@jpmorgan.com)
Tue, 18 Jul 1995 13:14:40 -0400 (EDT)
> I must admit that I did not check that proxying worked before releasing the
> code. I don't have a proxy server handy for the time beeing. Now that I have
> looked at code code I discovered a few typos releated to proxying. The
> following patch ought to make things work (but I have not tested it):
>
***
> The proxy code has moved from place to place during the development. I think
> the current location is reasonable. Martijn might be able to elaborate on
> this.
>
> Another matter is that the "get" script ought to have some way to set up
> proxying. Code donations are appreciated.
>
The patch to UserAgent.pm worked for me - I also took another good look
at the code and have cleared up my own confusion. That said, here is
a basically five line patch to "get" which adds a new option, -p <proxy>,
to enable you to use a proxy in requests. I hardcoded in http as the
method to proxy - I wasn't sure if that line should contain the whole list
of methods, or should try to grab the method from the URL and work on that.
This patch goes on top of the one you posted...
--- get Tue Jul 18 12:38:14 1995
+++ get Tue Jul 18 12:49:35 1995
@@ -157,4 +157,5 @@
$opt_i = undef; # if-modified-since
$opt_c = undef; # content type for POST
+$opt_p = undef; # proxy url
$opt_u = undef; # display method, URL and headers of request
@@ -167,5 +168,5 @@
$opt_v = undef; # print version
-unless (getopts("hvuUsedb:t:i:c:m:f")) {
+unless (getopts("hvuUsedb:t:i:c:m:p:f")) {
usage();
}
@@ -229,4 +230,8 @@
}
+if (defined $opt_p) {
+ $ua->proxy('http',$opt_p);
+}
+
$content = undef;
if ($allowed_methods{$method} eq "C") {
@@ -308,4 +313,5 @@
-f make request even if $0 believe method is illegal
-b <base> Use the specified URL as base
+ -p <proxy> Use the specified URL as a proxy server
-t <timeout> Set timeout value
-i <time> Set the If-Modified-Since header on the request
One other comment - I noticed that requests seem to go out with a header
like this:
GET http://archive.ny.jpmorgan.com/
Accept: */*
User-Agent: LWP get/1.06
This brings two comments to mind. First, should it be using the long form
syntax :
GET <URL> HTTP/1.0
and second, leaving the http:/ in there is, if I remember correctly, the
proxying notation. Should it be parsed into :
GET /archive.ny.jpmorgan.com
or GET /archive.ny.jpmorgan.com HTTP/1.0
instead?
Thanks again,
Joel