1 (* Copyright (C) 2009 Matthew Fluet.
2 * Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
3 * Jagannathan, and Stephen Weeks.
5 * MLton is released under a BSD-style license.
6 * See the file MLton-LICENSE for details.
9 (* Based on RFC 2616. *)
31 | Path of {path: Url.Path.t,
35 val toString: t -> string
40 datatype t = T of {major: int,
51 | AcceptCharset of string
52 | AcceptEncoding of string
53 | AcceptLanguage of string
54 | AcceptRanges of string
57 | Authorization of string
58 | CacheControl of string
59 | Connection of string
60 | ContentEncoding of string
61 | ContentLanguage of string
62 | ContentLength of int
63 | ContentLocation of string
64 | ContentMD5 of string
65 | ContentRange of string
66 | ContentType of string
72 | Extension of {name: string, value: string}
76 | LastModified of string
79 | ProxyAuthenticate of string
80 | ProxyConnection of string
82 | RetryAfter of string
86 | TransferEncoding of string
91 | WWWAuthenticate of string
94 val fromString: string -> t list Result.t
95 val input: In.t -> t list Result.t
96 val toString: t -> string
101 datatype t = T of {method: Method.t,
104 headers: Header.t list}
106 val input: In.t -> t Result.t
107 val layout: t -> Layout.t
108 val output: t * Out.t -> unit
109 val regexp: unit -> Regexp.Compiled.t
110 val requestLine: string -> {method: Method.t,
112 version: Version.t} option
113 val toString: t -> string
126 | Extension of string
131 | HTTPVersionNotSupported
132 | InternalServerError
138 | NonAuthoritativeInformation
147 | ProxyAuthenticationRequired
148 | RequestEntityTooLarge
151 | RequestedRangeNotSatisfiable
158 | UnsupportedMediaType
161 val code: t -> string
162 val fromString: string -> t (* string is a code, eg "502" *)
163 val reason: t -> string
168 datatype t = T of {headers: Header.t list,
172 val input: In.t -> t Result.t
173 val layout: t -> Layout.t
174 val output: t * Out.t -> unit
175 val regexp: unit -> Regexp.Compiled.t
176 val toString: t -> string
183 datatype t = Url | Multipart
190 val file: File.t -> t
191 val string: string -> t
195 T of {encoding: Encoding.t,
196 fields: {name: string,
197 value: Value.t} list}
202 headers: Header.t list,
204 proxy: {host: string, port: int} option,
209 functor TestHttp (S: HTTP): sig end =
216 ("TestHttp", fn () =>
217 Regexp.Compiled.matchesAll (Request.regexp (),
218 "CONNECT trading.etrade.com:443 HTTP/1.0\r\n")
220 isSome (Request.requestLine "GET http://Norma140.emp3.com/ HTTP/1.0\n")
224 "Date: Wed, 08 Mar 2000 09:26:18 GMT\r\n\
225 \Server: Apache/1.3.6 (Unix) (Red Hat/Linux)\r\n\
226 \Last-Modified: Thu, 02 Mar 2000 22:55:44 GMT\r\n\
227 \ETag: \"23a07c-2ae-38bef170\"\r\n\
228 \Accept-Ranges: bytes\r\n\
229 \Content-Length: 686\r\n\
230 \Connection: close\r\n\
231 \Content-Type: text/html\r\n"
232 val zzz = "GET http://www.nytimes.com/auth/chk_login?is_continue=true&URI=http%3A%2F%2Fwww.nytimes.com%2Flibrary%2Ftech%2Fyr%2Fmo%2Fbiztech%2Farticles%2F17blue.html&Tag=&site=&banner=&sweeps=&USERID=cypherpunk&PASSWORD=cypherpunk&SAVEOPTION=YES HTTP/1.0\r\n"
234 "Referer: http://www.nytimes.com/auth/chk_login?is_continue=true&URI=http%3A%2F%2Fwww.nytimes.com%2Flibrary%2Ftech%2Fyr%2Fmo%2Fbiztech%2Farticles%2F17blue.html&Tag=&site=&banner=&sweeps=&USERID=hqbovik&PASSWORD=hqbovik&SAVEOPTION=YES\r\nUser-Agent: Mozilla/4.7 [en]\r\nHost: www.nytimes.com\r\nAccept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*\r\nAccept-Encoding: gzip\r\nAccept-Language: en\r\nAccept-Charset: iso-8859-1,*,utf-8\r\nCookie: RMID=c603a30338b9ce60; NYT-S=0UtWyAdJ/Hc94BS7pHO0q4Pek6E1oJ.FMxFTIduykzwDgubECS6cqpWk.Duqut/D9GDBO6lz6cXYs0; PW=\161%.69,.)03\223; ID=\161%.69,.)03\223; RDB=C80200D6EF0000555301001E2719270101000000000002\r\n"
236 val s = "Cookie: PW=\161%.69\r\n"
237 in Result.isYes (Header.fromString s)