@@ -22,7 +22,7 @@ class type message = object
2222 method statusCode : int readonly_prop
2323 method statusMessage : js_string t readonly_prop
2424 method url : js_string t readonly_prop
25- method on_data : js_string t -> (js_string t -> unit ) callback -> unit meth
25+ method on_data : js_string t -> (Typed_array. arrayBuffer t -> unit ) callback -> unit meth
2626 method on_end : js_string t -> (unit -> unit ) callback -> unit meth
2727end
2828
@@ -56,7 +56,7 @@ let handle f (m : message t) =
5656 if m##.statusCode > = 200 && m##.statusCode < 300 then
5757 let s = ref " " in
5858 m##on_data (string " data" ) (wrap_callback (fun chunk ->
59- s := ! s ^ (to_string chunk)));
59+ s := ! s ^ (Typed_array.String. of_arrayBuffer chunk)));
6060 m##on_end (string " end" ) (wrap_callback (fun () ->
6161 if ! Verbose. v land 1 <> 0 then Format. printf " [ez_api] received:\n %s@." ! s;
6262 f (Ok ! s)))
@@ -75,7 +75,7 @@ let get ?(protocol=http) ?options url f =
7575let post ?(protocol =http) ?options url ~content f =
7676 if ! Verbose. v land 2 <> 0 then Format. printf " [ez_api] sent:\n %s@." content;
7777 let o = optdef options_to_jsoo options in
78- let req = protocol##get (string url) o (def @@ wrap_callback (handle f)) in
78+ let req = protocol##request (string url) o (def @@ wrap_callback (handle f)) in
7979 req##on_error (string " error" ) (wrap_callback (fun (e : err t ) ->
8080 f (Error (e##.code, Some (to_string e##.message)))));
8181 req##end_ (def (string content))
0 commit comments