Skip to content

Commit fa31483

Browse files
committed
Revert "Make possible to send files in xmlhttprequests"
This reverts commit 9e1d292. (This is an incompatible change with respect to 1.3.2.) Conflicts: lib/Makefile
1 parent 0478bea commit fa31483

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

lib/xmlHttpRequest.ml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ let encode_multipart boundary elements =
9797
(fun v ->
9898
ignore(b##push(Js.string ("--"^boundary^"\r\n")));
9999
match v with
100-
| name, `String value ->
100+
| name,`String value ->
101101
ignore(b##push_3(Js.string ("Content-Disposition: form-data; name=\"" ^ name ^ "\"\r\n\r\n"),
102102
value,
103103
Js.string "\r\n"));
104104
return ()
105-
| name, `File value ->
105+
| name,`File value ->
106106
File.readAsBinaryString (value :> File.blob Js.t)
107107
>>= (fun file ->
108108
ignore(b##push_4(Js.string ("Content-Disposition: form-data; name=\"" ^ name ^ "\"; filename=\""),
@@ -157,7 +157,7 @@ let extract_get_param url =
157157
let perform_raw_url
158158
?(headers = [])
159159
?content_type
160-
?(post_args:(string * Form.form_elt) list option)
160+
?(post_args:(string * string) list option)
161161
?(get_args=[])
162162
?(form_arg:Form.form_contents option)
163163
?(check_headers=(fun _ _ -> true))
@@ -167,21 +167,17 @@ let perform_raw_url
167167
let form_arg =
168168
match form_arg with
169169
| None ->
170-
(match post_args with
170+
( match post_args with
171171
| None -> None
172172
| Some post_args ->
173173
let contents = Form.empty_form_contents () in
174-
List.iter (fun (name, value) ->
175-
Form.append contents (name, value))
176-
post_args;
177-
Some contents)
174+
List.iter (fun (name,value) -> Form.append contents (name,`String (string value))) post_args;
175+
Some contents )
178176
| Some form_arg ->
179-
(match post_args with
177+
( match post_args with
180178
| None -> ()
181179
| Some post_args ->
182-
List.iter (fun (name, value) ->
183-
Form.append form_arg (name, value))
184-
post_args);
180+
List.iter (fun (name,value) -> Form.append form_arg (name,`String (string value))) post_args; );
185181
Some form_arg
186182
in
187183

@@ -299,3 +295,4 @@ let perform
299295
(Url.string_of_url url)
300296

301297
let get s = perform_raw_url s
298+

lib/xmlHttpRequest.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ exception Wrong_headers of (int * (string -> string option))
8686
val perform_raw_url :
8787
?headers:(string * string) list
8888
-> ?content_type:string
89-
-> ?post_args:((string * Form.form_elt) list)
89+
-> ?post_args:((string * string) list)
9090
-> ?get_args:((string * string) list) (* [] *)
9191
-> ?form_arg:Form.form_contents
9292
-> ?check_headers:(int -> (string -> string option) -> bool)
@@ -105,7 +105,7 @@ val perform_raw_url :
105105
val perform :
106106
?headers:(string * string) list
107107
-> ?content_type:string
108-
-> ?post_args:((string * Form.form_elt) list)
108+
-> ?post_args:((string * string) list)
109109
-> ?get_args:((string * string) list) (* [] *)
110110
-> ?form_arg:Form.form_contents
111111
-> ?check_headers:(int -> (string -> string option) -> bool)

0 commit comments

Comments
 (0)