Skip to content

Commit 9d2ceab

Browse files
author
Vincent Balat
committed
Making subtype non optional in content types
1 parent 52a68fe commit 9d2ceab

File tree

5 files changed

+15
-19
lines changed

5 files changed

+15
-19
lines changed

src/http/ocsigen_headers.ml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -237,20 +237,17 @@ let parse_content_type = function
237237
match String.split ';' s with
238238
| [] -> None
239239
| a::l ->
240-
let (typ, subtype) =
241-
try
242-
let typ, subtype = String.sep '/' a in (typ, Some subtype)
243-
with Not_found -> a, None
244-
in
245-
let params =
246-
try
247-
List.map (String.sep '=') l
248-
with Not_found -> []
249-
in
240+
try
241+
let typ, subtype = String.sep '/' a in
242+
let params =
243+
try
244+
List.map (String.sep '=') l
245+
with Not_found -> []
246+
in
250247
(*VVV If syntax error, we return no parameter at all *)
251-
Some ((typ, subtype), params)
248+
Some ((typ, subtype), params)
252249
(*VVV If syntax error in type, we return None *)
253-
250+
with Not_found -> None
254251

255252
let get_content_length http_frame =
256253
try

src/http/ocsigen_headers.mli

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ val find_all : string -> Ocsigen_http_frame.t -> string list
3535
val get_keepalive : Ocsigen_http_frame.Http_header.http_header -> bool
3636
val parse_cookies : string -> string CookiesTable.t
3737
val parse_mime_type : string -> string option * string option
38-
val get_host_from_host_header : Ocsigen_http_frame.t ->
38+
val get_host_from_host_header : Ocsigen_http_frame.t ->
3939
string option * int option
4040
val get_user_agent : Ocsigen_http_frame.t -> string
4141
val get_cookie_string : Ocsigen_http_frame.t -> string option
@@ -44,7 +44,8 @@ val get_if_unmodified_since : Ocsigen_http_frame.t -> float option
4444
val get_if_none_match : Ocsigen_http_frame.t -> string list option
4545
val get_if_match : Ocsigen_http_frame.t -> string list option
4646
val get_content_type : Ocsigen_http_frame.t -> string option
47-
val parse_content_type : string option -> ((string * string) * (string * string) list) option
47+
val parse_content_type
48+
: string option -> ((string * string) * (string * string) list) option
4849
val get_content_length : Ocsigen_http_frame.t -> int64 option
4950
val get_referer : Ocsigen_http_frame.t -> string option
5051
val get_referrer : Ocsigen_http_frame.t -> string option

src/server/ocsigen_extensions.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ type file_info = {
193193
filesize: int64;
194194
raw_original_filename: string;
195195
original_basename: string ;
196-
file_content_type:
197-
((string * string option) * (string * string) list) option;
196+
file_content_type: ((string * string) * (string * string) list) option;
198197
}
199198

200199
type request_info =

src/server/ocsigen_extensions.mli

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ type file_info = {
140140
filesize: int64;
141141
raw_original_filename: string;
142142
original_basename: string ;
143-
file_content_type:
144-
((string * string option) * (string * string) list) option;
143+
file_content_type: ((string * string) * (string * string) list) option;
145144
}
146145

147146
(** The request *)

src/server/ocsigen_server.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ let find_field field content_disp =
112112
type to_write =
113113
No_File of string * Buffer.t
114114
| A_File of (string * string * string * Unix.file_descr
115-
* ((string * string option) * (string * string) list) option)
115+
* ((string * string) * (string * string) list) option)
116116

117117
let counter = let c = ref (Random.int 1000000) in fun () -> c := !c + 1 ; !c
118118

0 commit comments

Comments
 (0)