Libwww suggestions

Roy T. Fielding (fielding@simplon.ICS.UCI.EDU)
Fri, 19 Aug 1994 12:22:20 -0700


------- Forwarded Message

Received: from Osiris.AC.HMC.Edu by paris.ics.uci.edu id aa05261;
          17 Aug 94 7:03 PDT
Received: (from jared@localhost) by osiris.ac.hmc.edu (8.6.8.1/8.6.7) id HAA02275; Wed, 17 Aug 1994 07:03:31 -0700
Date: Wed, 17 Aug 1994 07:03:31 -0700
Message-Id: <199408171403.HAA02275@osiris.ac.hmc.edu>
From: Jared_Rhine@hmc.edu
To: "Roy T. Fielding" <fielding@simplon.ICS.UCI.EDU>
Subject: Libwww suggestions
X-Attribution: JRhine

I pulled down libwww (v0.30) since I had a user who wanted to do
automatically pull down stock quotes.  In the course of setting this up, I
made a couple of tweaks to the package:

  * To make step 3 of the install directions (edit all the files to point to
    the perl binary, I stole the Plexus configuration stuff and made:

Makefile
--------
PERLBIN = /usr/bin/perl

FILES = get testbot testdates testescapes testlinks

configure:
  perl -i.orig config.pl PERLBIN=${PERLBIN} -- ${FILES}

config.pl
---------
# Stolen from plexus configuration
# This script is run manually as: config.pl -i.orig [PERLBIN=path -- files]

eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_]+=)(.*)/ && shift;

shift if $ARGV[0] eq '--';    # FOO=bar -- this=is_a_file

while (<>) {
    s:^#!/usr/public/bin/perl$:#!$PERLBIN:o if $. == 1; # special case
    close(ARGV) if eof;     # reset line number for next file
}
continue { print; }

  * This stock quote thing needed to use a POST method.  I couldn't get it
    to work until I added the following patch:

RCS file: RCS/wwwhttp.pl,v
retrieving revision 0.13
diff -c -r0.13 wwwhttp.pl
*** 0.13        1994/07/20 16:14:56
--- wwwhttp.pl  1994/08/17 13:18:46
***************
*** 89,94 ****
--- 89,99 ----
              $reqstr .= "$hd: $val\r\n";
          }
      }
+     if ($AllowedMethods{$method} == 2) {
+        local($length) = length($content);
+        $reqstr .= "Content-Length: $length\r\n";
+     }
+
      $reqstr .= "\r\n";
 
      if (!$port) { $port = 80; };   # The default HTTP port is always 80
  
    Is this a necessary patch?  I didn't look too carefully to try to get
    the overall structure, so I may have missed a mechanism to deal with
    adding a content-length for the POST type.  Or is the design to leave
    this up to the user?  Hmmm, since the POST specs say you can terminate a
    POST with an end-of-connection, I guess it's technically not mandatory
    to add a content-length, but I imagine the vast majority of the usage
    will be for posting forms.  Might want to note in whatever documentation
    is brewing that a '$headers{'Content-length',length($content)' is
    required in most cases.

A couple of comments:

  * It would be nice if the package fell through to `uname -n` if `hostname`
    didn't work.  I really don't want to put /usr/ucb back in my path.

-- 
Jared_Rhine@hmc.edu | Harvey Mudd College | http://www.hmc.edu/~jared/home.html

"Remember, only users lose drugs." -- from Richard Stueven

------- End of Forwarded Message