summaryrefslogtreecommitdiff
path: root/gemini
diff options
context:
space:
mode:
authorRyan Kavanagh <rak@rak.ac>2020-06-02 15:24:25 -0400
committerRyan Kavanagh <rak@rak.ac>2020-06-07 11:39:58 -0400
commitb6e597afe251c5a7c16b09794c77de3d6e9499f4 (patch)
treee0b1cd39ce258c9f2bbaa074370238c040f3f4cd /gemini
parentAdded to_canonical for mimetypes (diff)
Add an UNDEFINED status
Diffstat (limited to '')
-rw-r--r--gemini/geminiTransaction.ml52
-rw-r--r--gemini/geminiTransaction.mli3
2 files changed, 28 insertions, 27 deletions
diff --git a/gemini/geminiTransaction.ml b/gemini/geminiTransaction.ml
index 86be965..65b80ea 100644
--- a/gemini/geminiTransaction.ml
+++ b/gemini/geminiTransaction.ml
@@ -26,6 +26,7 @@ sig
| CERT_NOT_ACCEPTED
| FUTURE_CERT_REJECTED
| EXPIRED_CERT_REJECTED
+ | UNDEFINED of int
type mime_type = M.t
@@ -33,7 +34,7 @@ sig
val make_request : url:string -> request
- val int_to_status : int -> status option
+ val int_to_status : int -> status
val transaction : request -> (response, string) result Lwt.t
end
@@ -71,6 +72,7 @@ struct
| CERT_NOT_ACCEPTED
| FUTURE_CERT_REJECTED
| EXPIRED_CERT_REJECTED
+ | UNDEFINED of int
type response = status * mime_type * string
@@ -88,36 +90,34 @@ struct
{ host = host; port = port; url = r; }
let int_to_status = function
- | 10 -> Some INPUT
- | 20 -> Some SUCCESS
- | 21 -> Some SUCCESS_EOCSS
- | 30 -> Some REDIR_TEMP
- | 31 -> Some REDIR_PERM
- | 40 -> Some TEMP_FAIL
- | 41 -> Some SERVER_UNAVAILABLE
- | 42 -> Some CGI_ERROR
- | 43 -> Some PROXY_ERROR
- | 44 -> Some SLOW_DOWN
- | 50 -> Some PERM_FAIL
- | 51 -> Some NOT_FOUND
- | 52 -> Some GONE
- | 53 -> Some PROXY_REQ_REFUSED
- | 54 -> Some BAD_REQ
- | 60 -> Some CLIENT_CERT_REQUIRED
- | 61 -> Some TRANSIENT_CERT_REQUESTED
- | 62 -> Some AUTHORISED_CERT_REQUIRED
- | 63 -> Some CERT_NOT_ACCEPTED
- | 64 -> Some FUTURE_CERT_REJECTED
- | 65 -> Some EXPIRED_CERT_REJECTED
- | _ -> None
+ | 10 -> INPUT
+ | 20 -> SUCCESS
+ | 21 -> SUCCESS_EOCSS
+ | 30 -> REDIR_TEMP
+ | 31 -> REDIR_PERM
+ | 40 -> TEMP_FAIL
+ | 41 -> SERVER_UNAVAILABLE
+ | 42 -> CGI_ERROR
+ | 43 -> PROXY_ERROR
+ | 44 -> SLOW_DOWN
+ | 50 -> PERM_FAIL
+ | 51 -> NOT_FOUND
+ | 52 -> GONE
+ | 53 -> PROXY_REQ_REFUSED
+ | 54 -> BAD_REQ
+ | 60 -> CLIENT_CERT_REQUIRED
+ | 61 -> TRANSIENT_CERT_REQUESTED
+ | 62 -> AUTHORISED_CERT_REQUIRED
+ | 63 -> CERT_NOT_ACCEPTED
+ | 64 -> FUTURE_CERT_REJECTED
+ | 65 -> EXPIRED_CERT_REJECTED
+ | n -> UNDEFINED n
let status_parser : (status, string) result Angstrom.t =
let open Angstrom in
let status_of_string s =
match int_of_string_opt s with
- | Some n -> (match int_to_status n with
- | Some s -> Ok s
- | None -> Error ("Invalid status: " ^ s))
+ | Some n -> Ok (int_to_status n)
| None -> Error ("Invalid status: " ^ s) in
lift status_of_string (take 2) <?> "status"
diff --git a/gemini/geminiTransaction.mli b/gemini/geminiTransaction.mli
index b97967b..b31d9e0 100644
--- a/gemini/geminiTransaction.mli
+++ b/gemini/geminiTransaction.mli
@@ -26,6 +26,7 @@ sig
| CERT_NOT_ACCEPTED
| FUTURE_CERT_REJECTED
| EXPIRED_CERT_REJECTED
+ | UNDEFINED of int
type mime_type = M.t
@@ -33,7 +34,7 @@ sig
val make_request : url:string -> request
- val int_to_status : int -> status option
+ val int_to_status : int -> status
val transaction : request -> (response, string) result Lwt.t
end