Ticket #1: provisional-code-for-creating-request_uris-that-conform-with-rfc2616_.dpatch

File provisional-code-for-creating-request_uris-that-conform-with-rfc2616_.dpatch, 16.9 kB (added by bringert, 6 years ago)

Eric Kow's provisional patch

Line 
1
2New patches:
3
4[Provisional code for creating request-uris that conform with RFC2616.
5'Daniel McAllansmith <dm.maillists@gmail.com>'**20080331202400
6 Currently only abs_path request-uris are used.  This means that you can't get
7 resources via a proxy, which requires the use of absoluteURI request-uris.
8 This provisional code adds a RequestURI datatype that allows you to
9 discriminate between requests to an origin server, a proxy and requesting
10 server info.  Further changes to actually use this code are required, at
11 the least replacing the URI in Request with RequestURI and removing the use
12 of fixReq in simpleHTTP.
13] {
14hunk ./Network/HTTP.hs 236
15+-- | The request-uri that we will send to the server, conforming to
16+-- RFC2616, Section 5.1.2.  Note that we don't have a CONNECT
17+-- RequestMethod so the authority form is not currently implemented.
18+--
19+-- A RequestURI consists of a URI representing a resource on a server
20+-- and the type of request we will be making to that resource.
21+-- Depending upon the requestType parts of the resource URI may be
22+-- ignored, eg HostingServer will only use the host and port from the
23+-- resource URI.
24+data RequestURI = ReqURI { resource :: URI
25+                         , requestType :: RequestType
26+                         }
27+
28+instance Show RequestURI where
29+    show (ReqURI r HostingServer) = "*"
30+    show (ReqURI r FromOrigin)    = (show . clearURIScheme . clearURIAuth . normaliseURIPath) r
31+    show (ReqURI r ViaProxy)      = (show . clearURIUserInfo . normaliseURIPath) r
32+
33+normaliseURIPath u = if null (uriPath u) || head (uriPath u) /= '/'
34+                       then u { uriPath = '/' : uriPath u }
35+                       else u
36+
37+clearURIAuth u = u { uriAuthority = Nothing }
38+
39+clearURIScheme u = u { uriScheme = "" }
40+
41+clearURIUserInfo u = u { uriAuthority = (fmap (\ua -> ua { uriUserInfo = "" }) . uriAuthority) u }
42+
43+-- | Discriminate between making a request of the hosting server of a
44+-- resource, requesting a resource from an origin/gateway server and
45+-- requesting a resource via a proxy.
46+data RequestType = HostingServer | FromOrigin | ViaProxy
47+
48}
49
50[Tidy up RequestURI.
51Eric Kow <E.Y.Kow@brighton.ac.uk>**20080618144146] {
52hunk ./Network/HTTP.hs 126
53-    parseURIAuthority
54+    parseURIAuthority,
55+
56+    RequestURI(..),
57+    RequestType(..),
58+    defaultRequestURI,
59hunk ./Network/HTTP.hs 258
60+normaliseURIPath :: URI -> URI
61hunk ./Network/HTTP.hs 263
62+clearURIAuth :: URI -> URI
63hunk ./Network/HTTP.hs 266
64+clearURIScheme :: URI -> URI
65hunk ./Network/HTTP.hs 269
66+clearURIUserInfo :: URI -> URI
67hunk ./Network/HTTP.hs 272
68+defaultRequestURI :: URI -> RequestURI
69+defaultRequestURI u = ReqURI u FromOrigin
70+
71}
72
73[Plug RequestURI in (for better proxy support).
74Eric Kow <E.Y.Kow@brighton.ac.uk>**20080618144225] {
75hunk ./Network/Browser.hs 510
76-    let uri = rqURI rq in
77+    let uri = resource $ rqURI rq in
78hunk ./Network/Browser.hs 735
79-       let uri = rqURI rq
80+       let uri = resource $ rqURI rq
81hunk ./Network/Browser.hs 756
82-            NoProxy -> dorequest (uriAuth $ rqURI rq'') rq''
83+            NoProxy -> dorequest (uriAuth $ resource $ rqURI rq'') rq''
84hunk ./Network/Browser.hs 758
85-                let rq''' = case ath of
86-                                Nothing -> rq''
87-                                Just x  -> insertHeader HdrProxyAuthorization (withAuthority x rq'') rq''
88+                let uri''' = (rqURI rq'') { requestType = ViaProxy }
89+                    rq''' = case ath of
90+                                Nothing -> rq'' { rqURI = uri''' }
91+                                Just x  -> insertHeader HdrProxyAuthorization (withAuthority x rq'') $
92+                                           rq'' { rqURI = uri''' }
93hunk ./Network/Browser.hs 861
94-                                              ; let rq = rq { rqMethod=GET, rqURI=newuri', rqBody="" }
95+                                              ; let rq = rq { rqMethod=GET, rqURI=defaultRequestURI newuri', rqBody="" }
96hunk ./Network/Browser.hs 908
97-                                      request' (0,redirectcount+1,retrycount,True) (rq { rqURI=newuri' })
98+                                      request' (0,redirectcount+1,retrycount,True) (rq { rqURI=defaultRequestURI newuri' })
99hunk ./Network/Browser.hs 983
100-    Request { rqURI=uri
101+    Request { rqURI=defaultRequestURI uri
102hunk ./Network/Browser.hs 1007
103-                       , rqURI=u { uriQuery= '?' : enc }  -- What about old query?
104+                       , rqURI=defaultRequestURI $ u { uriQuery= '?' : enc }  -- What about old query?
105hunk ./Network/Browser.hs 1013
106-                        , rqURI=u
107+                        , rqURI=defaultRequestURI u
108hunk ./Network/HTTP.hs 293
109-     Request { rqURI       :: URI   -- ^ might need changing in future
110+     Request { rqURI       :: RequestURI
111+                                    -- ^ might need changing in future
112hunk ./Network/HTTP.hs 312
113-        show m ++ sp ++ alt_uri ++ sp ++ httpVersion ++ crlf
114+        show m ++ sp ++ show u ++ sp ++ httpVersion ++ crlf
115hunk ./Network/HTTP.hs 314
116-        where
117-            alt_uri = show $ if null (uriPath u) || head (uriPath u) /= '/'
118-                        then u { uriPath = '/' : uriPath u }
119-                        else u
120hunk ./Network/HTTP.hs 457
121-  -- we assume that this is the case, so we take the host name from
122-  -- the Host header if there is one, otherwise from the request-URI.
123-  -- Then we make the request-URI an abs_path and make sure that there
124-  -- is a Host header.
125hunk ./Network/HTTP.hs 461
126-                r { rqURI = (rqURI r){ uriScheme = "",
127-                                       uriAuthority = Nothing } }             
128+                r
129hunk ./Network/HTTP.hs 470
130-                             Nothing -> uriToAuthorityString (rqURI r)
131+                             Nothing -> uriToAuthorityString $ resource $ rqURI r
132hunk ./Network/HTTP.hs 580
133-                host = uriToAuthorityString uri
134+                host = uriToAuthorityString $ resource $ uri
135hunk ./Network/HTTP.hs 629
136-       return $ rslt `bindE` \(ftrs,bdy) -> Right (Request uri rm (hdrs++ftrs) bdy)
137+       let rUri = ReqURI uri FromOrigin
138+       return $ rslt `bindE` \(ftrs,bdy) -> Right (Request rUri rm (hdrs++ftrs) bdy)
139hunk ./test/get.hs 42
140-request uri = Request{ rqURI = uri,
141+request uri = Request{ rqURI = ReqURI uri ViaProxy,
142}
143
144Context:
145
146[Fix for socket close code.
147prb@mult.ifario.us**20080502192705]
148[Accept the empty string as a cookie value.
149Will Thompson <will@willthompson.co.uk>**20080426132046
150 http://wp.netscape.com/newsref/std/cookie_spec.html does not specify whether
151 a cookie's value can be the empty string, but there is no obvious reason not
152 to accept it.
153]
154[Bump version number to 3001.1.0. Incremented minor number since the patch from Eric Mertens extends the API.
155bjorn@bringert.net**20080305202825]
156[Export getRequestHead and processRequest, add support for custom RequestMethods
157Eric Mertens <emertens@galois.com>**20080305190759]
158[Include uriQuery in request line.
159bjorn@bringert.net**20080128094645]
160[Send abs_path as Request-URI to comply with HTTP 1.1 spec.
161'Daniel McAllansmith <dm.maillists@gmail.com>'**20080128053024
162 RFC2616 Section 5.1.2 specifies that abs_path MUST be used to identify a resource on a origin server or gateway, not absoluteURI which is for use with proxies.
163 
164 Change Request's Show instance to use /path/to/resource rather than
165 http://server/path/to/resource.
166]
167[Bump version to 3001.0.4
168bjorn@bringert.net**20071213122237]
169[Expose Network.HTTP.Headers in cabal file
170Eric Mertens <emertens@galois.com>**20071212220235
171 
172 Failure to do this breaks :browse functionality in GHCi
173 as well as makes these useful functions unavailable
174]
175[Resolved conflicts in Network.Stream.
176robin@shorestreet.com**20071203042948]
177[Resolve conflict in HTTP.cabal.
178robin@shorestreet.com**20071029195007]
179[Split Header functionality into Network.HTTP.Headers module.
180robin@shorestreet.com**20070725192851]
181[Added files to .cabal file, made deps explicit in Network.TCP module.
182robin@shorestreet.com**20070725184005]
183[Refactored Network.Stream.
184robin@shorestreet.com**20070725061114]
185[Made more deps explicit.
186robin@shorestreet.com**20070724054038]
187[Made dependencies explicit in import statements.
188robin@shorestreet.com**20070724043419]
189[Bumped version number to 3001.0.3.
190bjorn@bringert.net**20071130225017]
191[Change myrecv to allow a 0 length. Suggested by Eric Mertens.
192bjorn@bringert.net**20071130224542
193 On Wed, 2007-08-15 at 23:25 +0200, Bjorn Bringert wrote:
194 Why doesn't the existing code work? Does recv fail when given 0?
195 
196 On Nov 30, 2007, at 23:36 , Eric Mertens wrote:
197 Yes, recv can not cope with an argument of 0
198 
199 http://darcs.haskell.org/packages/network/Network/Socket.hsc
200 
201 recv :: Socket -> Int -> IO String
202 recv sock l = recvLen sock l >>= \ (s,_) -> return s
203 
204 recvLen :: Socket -> Int -> IO (String, Int)
205 recvLen sock@(MkSocket s _family _stype _protocol status) nbytes
206  | nbytes <= 0 = ioError (mkInvalidRecvArgError "Network.Socket.recv")
207 
208]
209[Set version number to 3001.0.2.
210bjorn@bringert.net**20071118211601]
211[Change version to 3001.0.1.
212bjorn@bringert.net**20071117212431]
213[Don't treat any chunk size starting with '0' as a 0 chunk size.
214bjorn@bringert.net**20071117212214
215 Radosław Grzanka reported that Network.HTTP can't get http://www.podshow.com/feeds/gbtv.xml, see http://article.gmane.org/gmane.comp.lang.haskell.cafe/31783
216 
217 This turned out to be a bug in how Network.HTTP handled Chunked Transfer Encoding. The web server sent the chunk size as "00004000" (according to RFC 2616 this can be non-empty sequence of hex digits). However, Network.HTTP treated any chunk size starting with '0' as a chunk size of 0, which indicates the end of the chunked encoding.
218]
219[TAG 3001.0.0
220Duncan Coutts <duncan@haskell.org>**20071021133823]
221[Fix building with ghc-6.4 and base-1.0
222Duncan Coutts <duncan@haskell.org>**20071017225318
223 Also drop -O since Cabal does that automatically now.
224]
225[Added DELETE method.
226Greg Heartsfield <scsibug@imap.cc>**20070919075758]
227[Use Cabal configurations.
228bjorn@bringert.net**20071008204007]
229[Exporting ResponseCode from Network.HTTP
230ricky@dtek.chalmers.se**20070423155719]
231[WWW-Authenticate parsing bug.
232bjorn@bringert.net**20070625204602
233 RFC1945 says a challenge matches:
234 
235 challenge      = auth-scheme 1*SP realm *( "," auth-param )
236 
237 but, as I understand it, the "1*SP" term is not permitted. The fix is of
238 course simple:
239 
240 With this I can successfully perform Basic authentication against my cheap
241 ADSL router.
242 
243 Patch by cb224@cs.york.ac.uk
244]
245[Updated authentication scheme names
246jgbailey@gmail.com**20070613233759
247 
248 
249 When authenticating, the HTTP library
250 responded with "basic" or "digest". Web
251 servers expect "Basic" or "Digest", and some
252 are case-sensitive. THerefore, this update is necessary.
253 
254]
255[Added support for proxies with ports
256jgbailey@gmail.com**20070612212844
257 
258 A proxy can be both a host name with a port. This patch adds support for proxies that use a port other than 80.
259 
260 
261]
262[get rid of annoying cpp include kludge
263alex@happs.org**20070216191216]
264[Changed version number to 3000.0.0 to avoid ordering problems with old date-based version numbers.
265bjorn@bringert.net**20070211094535]
266[Changed version number scheme. Set version number to 1.0.
267bjorn@bringert.net**20070206143514]
268[Renamed http.cabal to HTTP.cabal.
269bjorn@bringert.net**20070206111455]
270[Bumped version number.
271bjorn@bringert.net**20070206111242]
272[Export authority stuff from Network.Browser.
273bjorn@bringert.net**20070206110917]
274[Use the non-deprecated Network.URI API
275trebla@vex.net**20070201210541]
276[Added -fwarn-missing-signatures. Added type signatures for defaultCookieFilter, userCookieFilter, setCookies, getCookies and defaultGETRequest.
277bjorn@bringert.net**20070129202633]
278[Added type signature for Network.Browser.request.
279bjorn@bringert.net**20070129201740]
280[Allowing - and : in cookie names/values, plus allowing a trailing semicolon in cookie value.
281bakert@gmail.com**20070111105703]
282[Fixed README typo.
283bjorn@bringert.net**20061226230117]
284[Set content-type: application/x-www-form-urlencoded in formToRequest. Patch by Artem Gr.
285bringert@cs.chalmers.se**20061114125602
286 Artem Gr wrote:
287 > The "Haskell HTTP package", present in http://haskell.org/http/,
288 > contains the formToRequest, which does not work, because it lacks the
289 > proper Content-Type header definition. Adding /Header HdrContentType
290 > "application/x-www-form-urlencoded"/ to the /rqHeaders/ of the /Request/
291 > solves the problem. Attached is the patch.
292]
293[Removed debian directory, as requested by haskell-http Debian maintainer Arjan Oosting.
294bjorn@bringert.net**20060811203429]
295[s/BSD4/BSD3/. Dunno where that came from.
296bjorn@bringert.net**20060707085613]
297[Added other-modules and -O according to patch by dcoutts. Couldn't apply his patch because of a darcs bug (!). Bumped version number.
298bjorn@bringert.net**20060707085029]
299[Removed obsolote references to the browser package from the README.
300bjorn@bringert.net**20060707083845]
301[Copied the Base64, MD5 and MD5Aux modules from the Crypto package to Network.HTTP and merged the http and browser packages back together.
302bjorn@bringert.net**20060705194820]
303[Moved the browser module to a separate package, as suggested by shapr.
304bjorn@bringert.net**20060423132859]
305[Cleaned up some haddock comments.
306bringert@cs.chalmers.se**20060327133857]
307[Added basic server-side functions and modularised
308Simon Foster <S.Foster@dcs.shef.ac.uk>**20060324201059
309  - Split module up into to sepearate Network.[Stream,TCP,HTTP] modules
310  - Created functions receiveHTTP and responseHTTP to allow server side interactions
311    (although 100-continue is unsupported and I haven't checked for standard compliancy).
312  - Pulled the transfer functions from sendHTTP to global scope to allow access by
313    above functions.
314]
315[Make Network.Browser support servers in different ports
316Einar Karttunen <ekarttun@cs.helsinki.fi>**20060302150224]
317[Make BrowserAction a Functor
318Einar Karttunen <ekarttun@cs.helsinki.fi>**20060302150203]
319[Handle GET requests with query string
320Einar Karttunen <ekarttun@cs.helsinki.fi>**20060221235500]
321[Don't leave socket half-open on failed connect. Patch by Samuel Bronson.
322bjorn@bringert.net**20060115203624]
323[Post requests should not add the query parameters to the URI
324Einar Karttunen <ekarttun@cs.helsinki.fi>**20051216193432]
325[Update version number.
326bjorn@bringert.net**20051122232535]
327[Added simpleHTTP_, which takes a Stream argument.
328bjorn@bringert.net**20050830084009]
329[ Added dependency on the base package. Patch by Henning GÃŒnther.
330bjorn@bringert.net**20050818225020]
331[Fixed bugs in writeBlock implementations that would resend the same data over and over. Changes by Lemmih.
332bjorn@bringert.net**20050614180545]
333[Fixed typo in dist name.
334bjorn@bringert.net**20050505192119]
335[Fixed haddock comments so that they parse.
336bjorn@bringert.net**20050505191121]
337[Updated build system and cabal-description.
338bjorn@bringert.net**20050505191006]
339[Use Base64 and MD5 from the Crypto package.
340bjorn@bringert.net**20050505190723]
341[Export Proxy type from Browser, as suggested by Uwe Schmidt.
342bjorn@bringert.net**20050413104916]
343[Fixed homepage url in cabal file
344bjorn@bringert.net**20050328212813]
345[Updated to support GHC 6.4: more cabal fields, Setup.lhs uses runghc, use new Network.URI, changed moulde for importing som IO error functions.
346bjorn@bringert.net**20050328212438]
347[Moved to http.cabal and changed contents to be compatible with current Cabal.
348bjorn@bringert.net**20050218223528]
349[Catch EOF exceptions thrown by recv when 0 bytes are read. Patch by John Goerzen.
350bjorn@bringert.net**20050218220503
351 
352 Description from John Goerzen:
353 
354 > First, even though I am sending an accurate Content-Length header with
355 > my POST message, the server is timing out and returning a 500 Internal
356 > Server Error document.
357 
358 Looks like that was a server bug.
359 
360 > Second, after reading that error document, Network.HTTP is generating an
361 > error of its own.  Here's an strace illustrating it:
362 
363 This one was a bug in HTTP.  Actually, I am stunned that nobody found it
364 before, because it looks to me that it would cause an exception to be
365 raised on every single HTTP hit.
366 
367 It turns out that Network.Socket.recv raises an EOF error when it gets
368 back 0 bytes of data.  HTTP is expecting it to return an empty list for
369 some reason.
370 
371]
372[minor debian packaging fixes
373ganesh@earth.li**20041213235450]
374[add debian/copyright file
375ganesh@earth.li**20041213235441]
376[LICENSE now covers entire package, added all contributors to LICENSE.
377bjorn@bringert.net**20041213230231]
378[Support '.' characters in cookie names
379ganesh@earth.li**20041213010128]
380[Initial debianisation
381ganesh@earth.li**20041213002245]
382[dependencies fixes
383ganesh@earth.li**20041213001849]
384[Added -package posix to work around missing posix package dependency in current version of Cabal.
385bjorn@bringert.net**20041113133508]
386[distclean now removes Setup.o and Setup.hi
387bjorn@bringert.net**20041113132459]
388[Added patch from Andre Furtado which removes the trailing ampersand in urlEncodeVars
389bjorn@bringert.net**20041015151040]
390[Imported current HTTP and Browser module versions.
391bjorn@bringert.net**20041015145806]
392Patch bundle hash:
3935d796dfbb44cadf8ab6ec473d0bb7f781b990a5f