Skip to content
This repository
tag: v1827
Fetching contributors…

Cannot retrieve contributors at this time

file 269 lines (238 sloc) 9.485 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
(*
Copyright © 2011 MLstate

This file is part of OPA.

OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.

OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.

You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*)
(* Generated by mkrp.ml - Wed, 15 Dec 2010 12:31:00 GMT *)
open Requestdef
open RequestType

exception ParseFail_hdr of int

let hdr_scmp s1 s2 m n =
  let p = ref m in
  while !p < n && Char.lowercase (String.unsafe_get s1 (!p)) = Char.lowercase (String.unsafe_get s2 (!p)) do incr p done;
  !p = n

let hdr_fail (_:string -> int -> int -> [`string of string | `value of (string * string option) list] RequestHeader.t -> int -> request_header -> [`string of string | `value of (string * string option) list] RequestHeader.t) (_hdr:string) (_hdrlen:int) (nxt:int) (_rh:[`string of string | `value of (string * string option) list] RequestHeader.t) = raise (ParseFail_hdr nxt)

let hdr_tab = Array.init 55 (fun _ -> Array.make 56 hdr_fail)

let hdrAc rpfn hdr hdrlen nxt rh =
  if hdr_scmp hdr "Accept-Encoding" 2 15
  then rpfn hdr hdrlen nxt rh 15 `Accept_Encoding
  else if hdr_scmp hdr "Accept-Language" 2 15
  then rpfn hdr hdrlen nxt rh 15 `Accept_Language
  else if hdr_scmp hdr "Accept-Charset" 2 14
  then rpfn hdr hdrlen nxt rh 14 `Accept_Charset
  else if hdr_scmp hdr "Accept" 2 6
  then rpfn hdr hdrlen nxt rh 6 `Accept
  else raise (ParseFail_hdr nxt)
let _ = hdr_tab.(0).(2) <- hdrAc
let _ = hdr_tab.(32).(2) <- hdrAc
let _ = hdr_tab.(0).(34) <- hdrAc
let _ = hdr_tab.(32).(34) <- hdrAc

let hdrAl rpfn hdr hdrlen nxt rh =
  if hdr_scmp hdr "Allow" 2 5
  then rpfn hdr hdrlen nxt rh 5 `Allow
  else raise (ParseFail_hdr nxt)
let _ = hdr_tab.(0).(11) <- hdrAl
let _ = hdr_tab.(32).(11) <- hdrAl
let _ = hdr_tab.(0).(43) <- hdrAl
let _ = hdr_tab.(32).(43) <- hdrAl

let hdrAu rpfn hdr hdrlen nxt rh =
  if hdr_scmp hdr "Authorization" 2 13
  then rpfn hdr hdrlen nxt rh 13 `Authorization
  else raise (ParseFail_hdr nxt)
let _ = hdr_tab.(0).(20) <- hdrAu
let _ = hdr_tab.(32).(20) <- hdrAu
let _ = hdr_tab.(0).(52) <- hdrAu
let _ = hdr_tab.(32).(52) <- hdrAu

let hdrCa rpfn hdr hdrlen nxt rh =
  if hdr_scmp hdr "Cache-Control" 2 13
  then rpfn hdr hdrlen nxt rh 13 `Cache_Control
  else raise (ParseFail_hdr nxt)
let _ = hdr_tab.(2).(0) <- hdrCa
let _ = hdr_tab.(34).(0) <- hdrCa
let _ = hdr_tab.(2).(32) <- hdrCa
let _ = hdr_tab.(34).(32) <- hdrCa

let hdrCo rpfn hdr hdrlen nxt rh =
  if hdr_scmp hdr "Content-Disposition" 2 19
  then rpfn hdr hdrlen nxt rh 19 `Content_Disposition
  else if hdr_scmp hdr "Content-Language" 2 16
  then rpfn hdr hdrlen nxt rh 16 `Content_Language
  else if hdr_scmp hdr "Content-Location" 2 16
  then rpfn hdr hdrlen nxt rh 16 `Content_Location
  else if hdr_scmp hdr "Content-Encoding" 2 16
  then rpfn hdr hdrlen nxt rh 16 `Content_Encoding
  else if hdr_scmp hdr "Content-Length" 2 14
  then rpfn hdr hdrlen nxt rh 14 `Content_Length
  else if hdr_scmp hdr "Content-Range" 2 13
  then rpfn hdr hdrlen nxt rh 13 `Content_Range
  else if hdr_scmp hdr "Content-Type" 2 12
  then rpfn hdr hdrlen nxt rh 12 `Content_Type
  else if hdr_scmp hdr "Content-MD5" 2 11
  then rpfn hdr hdrlen nxt rh 11 `Content_MD5
  else if hdr_scmp hdr "Connection" 2 10
  then rpfn hdr hdrlen nxt rh 10 `Connection
  else if hdr_scmp hdr "Cookie" 2 6
  then rpfn hdr hdrlen nxt rh 6 `Cookie
  else raise (ParseFail_hdr nxt)
let _ = hdr_tab.(2).(14) <- hdrCo
let _ = hdr_tab.(34).(14) <- hdrCo
let _ = hdr_tab.(2).(46) <- hdrCo
let _ = hdr_tab.(34).(46) <- hdrCo

let hdrDa rpfn hdr hdrlen nxt rh =
  if hdr_scmp hdr "Date" 2 4
  then rpfn hdr hdrlen nxt rh 4 `Date
  else raise (ParseFail_hdr nxt)
let _ = hdr_tab.(3).(0) <- hdrDa
let _ = hdr_tab.(35).(0) <- hdrDa
let _ = hdr_tab.(3).(32) <- hdrDa
let _ = hdr_tab.(35).(32) <- hdrDa

let hdrEx rpfn hdr hdrlen nxt rh =
  if hdr_scmp hdr "Expires" 2 7
  then rpfn hdr hdrlen nxt rh 7 `Expires
  else if hdr_scmp hdr "Expect" 2 6
  then rpfn hdr hdrlen nxt rh 6 `Expect
  else raise (ParseFail_hdr nxt)
let _ = hdr_tab.(4).(23) <- hdrEx
let _ = hdr_tab.(36).(23) <- hdrEx
let _ = hdr_tab.(4).(55) <- hdrEx
let _ = hdr_tab.(36).(55) <- hdrEx

let hdrFr rpfn hdr hdrlen nxt rh =
  if hdr_scmp hdr "From" 2 4
  then rpfn hdr hdrlen nxt rh 4 `From
  else raise (ParseFail_hdr nxt)
let _ = hdr_tab.(5).(17) <- hdrFr
let _ = hdr_tab.(37).(17) <- hdrFr
let _ = hdr_tab.(5).(49) <- hdrFr
let _ = hdr_tab.(37).(49) <- hdrFr

let hdrHo rpfn hdr hdrlen nxt rh =
  if hdr_scmp hdr "Host" 2 4
  then rpfn hdr hdrlen nxt rh 4 `Host
  else raise (ParseFail_hdr nxt)
let _ = hdr_tab.(7).(14) <- hdrHo
let _ = hdr_tab.(39).(14) <- hdrHo
let _ = hdr_tab.(7).(46) <- hdrHo
let _ = hdr_tab.(39).(46) <- hdrHo

let hdrIf rpfn hdr hdrlen nxt rh =
  if hdr_scmp hdr "If-Unmodified-Since" 2 19
  then rpfn hdr hdrlen nxt rh 19 `If_Unmodified_Since
  else if hdr_scmp hdr "If-Modified-Since" 2 17
  then rpfn hdr hdrlen nxt rh 17 `If_Modified_Since
  else if hdr_scmp hdr "If-None-Match" 2 13
  then rpfn hdr hdrlen nxt rh 13 `If_None_Match
  else if hdr_scmp hdr "If-Range" 2 8
  then rpfn hdr hdrlen nxt rh 8 `If_Range
  else if hdr_scmp hdr "If-Match" 2 8
  then rpfn hdr hdrlen nxt rh 8 `If_Match
  else raise (ParseFail_hdr nxt)
let _ = hdr_tab.(8).(5) <- hdrIf
let _ = hdr_tab.(40).(5) <- hdrIf
let _ = hdr_tab.(8).(37) <- hdrIf
let _ = hdr_tab.(40).(37) <- hdrIf

let hdrLa rpfn hdr hdrlen nxt rh =
  if hdr_scmp hdr "Last-Modified" 2 13
  then rpfn hdr hdrlen nxt rh 13 `Last_Modified
  else raise (ParseFail_hdr nxt)
let _ = hdr_tab.(11).(0) <- hdrLa
let _ = hdr_tab.(43).(0) <- hdrLa
let _ = hdr_tab.(11).(32) <- hdrLa
let _ = hdr_tab.(43).(32) <- hdrLa

let hdrMa rpfn hdr hdrlen nxt rh =
  if hdr_scmp hdr "Max-Forwards" 2 12
  then rpfn hdr hdrlen nxt rh 12 `Max_Forwards
  else raise (ParseFail_hdr nxt)
let _ = hdr_tab.(12).(0) <- hdrMa
let _ = hdr_tab.(44).(0) <- hdrMa
let _ = hdr_tab.(12).(32) <- hdrMa
let _ = hdr_tab.(44).(32) <- hdrMa

let hdrNe rpfn hdr hdrlen nxt rh =
  if hdr_scmp hdr "NewCookie" 2 9
  then rpfn hdr hdrlen nxt rh 9 `NewCookie
  else raise (ParseFail_hdr nxt)
let _ = hdr_tab.(13).(4) <- hdrNe
let _ = hdr_tab.(45).(4) <- hdrNe
let _ = hdr_tab.(13).(36) <- hdrNe
let _ = hdr_tab.(45).(36) <- hdrNe

let hdrPr rpfn hdr hdrlen nxt rh =
  if hdr_scmp hdr "Proxy-Authorization" 2 19
  then rpfn hdr hdrlen nxt rh 19 `Proxy_Authorization
  else if hdr_scmp hdr "Pragma" 2 6
  then rpfn hdr hdrlen nxt rh 6 `Pragma
  else raise (ParseFail_hdr nxt)
let _ = hdr_tab.(15).(17) <- hdrPr
let _ = hdr_tab.(47).(17) <- hdrPr
let _ = hdr_tab.(15).(49) <- hdrPr
let _ = hdr_tab.(47).(49) <- hdrPr

let hdrRe rpfn hdr hdrlen nxt rh =
  if hdr_scmp hdr "ReqRange" 2 8
  then rpfn hdr hdrlen nxt rh 8 `ReqRange
  else if hdr_scmp hdr "Referer" 2 7
  then rpfn hdr hdrlen nxt rh 7 `Referer
  else raise (ParseFail_hdr nxt)
let _ = hdr_tab.(17).(4) <- hdrRe
let _ = hdr_tab.(49).(4) <- hdrRe
let _ = hdr_tab.(17).(36) <- hdrRe
let _ = hdr_tab.(49).(36) <- hdrRe

let hdrTE rpfn hdr hdrlen nxt rh =
  if true
  then rpfn hdr hdrlen nxt rh 2 `TE
  else raise (ParseFail_hdr nxt)
let _ = hdr_tab.(19).(4) <- hdrTE
let _ = hdr_tab.(51).(4) <- hdrTE
let _ = hdr_tab.(19).(36) <- hdrTE
let _ = hdr_tab.(51).(36) <- hdrTE

let hdrTr rpfn hdr hdrlen nxt rh =
  if hdr_scmp hdr "Transfer-Encoding" 2 17
  then rpfn hdr hdrlen nxt rh 17 `Transfer_Encoding
  else if hdr_scmp hdr "Trailer" 2 7
  then rpfn hdr hdrlen nxt rh 7 `Trailer
  else raise (ParseFail_hdr nxt)
let _ = hdr_tab.(19).(17) <- hdrTr
let _ = hdr_tab.(51).(17) <- hdrTr
let _ = hdr_tab.(19).(49) <- hdrTr
let _ = hdr_tab.(51).(49) <- hdrTr

let hdrUp rpfn hdr hdrlen nxt rh =
  if hdr_scmp hdr "Upgrade" 2 7
  then rpfn hdr hdrlen nxt rh 7 `Upgrade
  else raise (ParseFail_hdr nxt)
let _ = hdr_tab.(20).(15) <- hdrUp
let _ = hdr_tab.(52).(15) <- hdrUp
let _ = hdr_tab.(20).(47) <- hdrUp
let _ = hdr_tab.(52).(47) <- hdrUp

let hdrUs rpfn hdr hdrlen nxt rh =
  if hdr_scmp hdr "User-Agent" 2 10
  then rpfn hdr hdrlen nxt rh 10 `User_Agent
  else raise (ParseFail_hdr nxt)
let _ = hdr_tab.(20).(18) <- hdrUs
let _ = hdr_tab.(52).(18) <- hdrUs
let _ = hdr_tab.(20).(50) <- hdrUs
let _ = hdr_tab.(52).(50) <- hdrUs

let hdrVi rpfn hdr hdrlen nxt rh =
  if hdr_scmp hdr "Via" 2 3
  then rpfn hdr hdrlen nxt rh 3 `Via
  else raise (ParseFail_hdr nxt)
let _ = hdr_tab.(21).(8) <- hdrVi
let _ = hdr_tab.(53).(8) <- hdrVi
let _ = hdr_tab.(21).(40) <- hdrVi
let _ = hdr_tab.(53).(40) <- hdrVi

let hdrWa rpfn hdr hdrlen nxt rh =
  if hdr_scmp hdr "Warning" 2 7
  then rpfn hdr hdrlen nxt rh 7 `Warning
  else raise (ParseFail_hdr nxt)
let _ = hdr_tab.(22).(0) <- hdrWa
let _ = hdr_tab.(54).(0) <- hdrWa
let _ = hdr_tab.(22).(32) <- hdrWa
let _ = hdr_tab.(54).(32) <- hdrWa

let hdr_mms = [|('A','w');('A','x')|]

let hdr_call rpfn hdr hdrlen nxt rh =
  let c0 = String.unsafe_get hdr 0 in
  let c1 = String.unsafe_get hdr 1 in
  if c0 < 'A' || c0 > 'w' then raise (ParseFail_hdr nxt);
  if c1 < 'A' || c1 > 'x' then raise (ParseFail_hdr nxt);
  hdr_tab.((Char.code c0)-65).((Char.code c1)-65) rpfn hdr hdrlen nxt rh
Something went wrong with that request. Please try again.