-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from c-cube/simon/multipart-form
library for multipart form data handling
- Loading branch information
Showing
18 changed files
with
688 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
open Utils_ | ||
|
||
type t = { kind: string; name: string option; filename: string option } | ||
|
||
(** Simple display *) | ||
let to_string (self : t) = | ||
let stropt = function | ||
| None -> "None" | ||
| Some s -> spf "%S" s | ||
in | ||
spf "{kind=%S; name=%s; filename=%s}" self.kind (stropt self.name) | ||
(stropt self.filename) | ||
|
||
let parse (hs : Tiny_httpd.Headers.t) : t option = | ||
match Tiny_httpd.Headers.get "content-disposition" hs with | ||
| None -> None | ||
| Some s -> | ||
(match String.split_on_char ';' s with | ||
| [] -> | ||
failwith (Printf.sprintf "multipart: invalid content-disposition %S" s) | ||
| kind :: tl -> | ||
let name = ref None in | ||
let filename = ref None in | ||
List.iter | ||
(fun s -> | ||
match Utils_.split1_on ~c:'=' @@ String.trim s with | ||
| Some ("name", v) -> name := Some (Utils_.remove_quotes v) | ||
| Some ("filename", v) -> filename := Some (Utils_.remove_quotes v) | ||
| _ -> ()) | ||
tl; | ||
Some { kind; name = !name; filename = !filename }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
(library | ||
(name tiny_httpd_multipart_form_data) | ||
(public_name tiny_httpd.multipart-form-data) | ||
(synopsis "Port of multipart-form-data for tiny_httpd") | ||
(libraries iostream tiny_httpd)) |
Oops, something went wrong.