[Haskell] New version of the HTTP module

Graham Klyne GK at ninebynine.org
Wed Mar 17 14:05:00 EST 2004


At 11:18 17/03/04 +0100, Bjorn Bringert wrote:
>I have reverted the type of the exported openTCP to String -> IO
>Connection, it now always uses port 80 like the old version did. Instead 
>there is an internal function openTCPPort that takes a port number. I will 
>try to have a look at the Browser module to see what needs to be done to 
>make it support arbitrary port numbers and if it needs any other updates.
>
>An updated version of HTTP.hs is available at 
>http://www.dtek.chalmers.se/~d00bring/haskell-xml-rpc/HTTP.hs

OK, that works.

I just re-ran the HXml Toolbox HUnitExample test successfully, using the 
new HTTP module (with some further edits) and my new URI module.  I also 
had to apply a small edits to Browser.hs (to include Proxy in the export list).

I am finding that there are some (easily fixed) incompatibilities with my 
revised Network.URI module.  (I also note that the HTTP module duplicates 
the Authority-parsing functionality that is also present in my Network.URI 
module, but that can be sorted out later.)

In my module, I changed the structure of the URI datatype, though I do 
provide functions to access components with their original 
names.  Unfortunately, the HTTP module makes some use of the "value { 
component=value }" syntax to define new URI values, which is not 
compatible.  If we are to adopt my version, these instances will need 
changing.  This will, in turn, require some synchronization of the change-over.

Here are the differences:
[[
Compare: (<)D:\Cvs\DEV\HaskellUtils\Network\HTTP.hs (46201 bytes)
    with: (>)D:\Cvs\DEV\HaskellUtils\Network\HTTP-bjorn.hs (45931 bytes)

13,15c13
< -- ** Changes by Graham Klyne:
< --      - export httpVersion
< --      - use new URI module (similar to old, but uses revised URI datatype)
---
85d81
<     httpVersion,        -- [GK]
498,499c493,494
<             alt_uri = show $ if null (uriPath u) || head (uriPath u) /= '/'
<                         then u { uriPath = '/' : uriPath u }
---
 >             alt_uri = show $ if null (path u) || head (path u) /= '/'
 >                         then u { path = '/' : path u }
985,986c980
<                  -- r { rqURI = (rqURI r){ scheme = "", authority = "" } }
<                  r { rqURI = (rqURI r){ uriScheme = "", uriAuthority = 
Nothing } }
---
 >                  r { rqURI = (rqURI r){ scheme = "", authority = "" } }
]]

My full codebase for HTTP and URI can be seen at:
   http://www.ninebynine.org/Software/HaskellUtils/Network/

My suggestion would be that we make the change-over by moving these to the 
library CVS as a single unit.  But I guess we should see if the URI changes 
are going to cause any other similar problems.

Do we have a stand-alone test harness for the HTTP code?  I've been using 
the HXml Toolbox unit tests.

#g


------------
Graham Klyne
For email:
http://www.ninebynine.org/#Contact



More information about the Libraries mailing list