Skip to content

Commit fed22b0

Browse files
authored
Merge pull request #119 from maxtori/nodejs-callback-type
fix nodejs callback type
2 parents 1300836 + 722bed0 commit fed22b0

File tree

2 files changed

+10
-23
lines changed

2 files changed

+10
-23
lines changed

.github/workflows/workflow.yml

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,43 +16,30 @@ jobs:
1616
matrix:
1717
os:
1818
- ubuntu-latest
19-
ocaml-version:
19+
- macos-latest
20+
ocaml-compiler:
2021
- 4.14.1
2122

2223
runs-on: ${{ matrix.os }}
2324

2425
steps:
2526
- name: Checkout code
26-
uses: actions/checkout@v2
27+
uses: actions/checkout@v3
2728

28-
- name: Retrieve opam cache
29-
uses: actions/cache@v2
30-
id: cache-opam
29+
- name: Use OCaml ${{ matrix.ocaml-compiler }}
30+
uses: ocaml/setup-ocaml@v2
3131
with:
32-
path: ~/.opam
33-
key: v1-${{ runner.os }}-opam-${{ matrix.ocaml-version }}-${{ hashFiles('ez_api.opam') }}
34-
restore-keys: |
35-
v1-${{ runner.os }}-opam-${{ matrix.ocaml-version }}-
36-
37-
- name: Use OCaml ${{ matrix.ocaml-version }}
38-
uses: avsm/setup-ocaml@v1
39-
with:
40-
ocaml-version: ${{ matrix.ocaml-version }}
32+
ocaml-compiler: ${{ matrix.ocaml-compiler }}
4133

4234
- name: Install system packages required by opam packages
43-
run: opam depext --yes --update geoip ocurl tls
35+
run: opam depext --update geoip ocurl tls
4436

4537
- name: Install opam packages
46-
if: steps.cache-opam.outputs.cache-hit != 'true'
4738
run: |
4839
opam pin add websocket-httpaf.~dev https://github.com/anmonteiro/websocket-httpaf.git
4940
opam pin add websocket-httpaf-lwt.~dev https://github.com/anmonteiro/websocket-httpaf.git
5041
opam install $(opam show -f depopts: . | sed -e 's/{.*}//g' -e 's/"//g')
5142
opam install . --deps-only --with-doc --with-test
5243
53-
- name: Check the consistency of installed opam packages
54-
if: steps.cache-opam.outputs.cache-hit == 'true'
55-
run: opam upgrade --fixup
56-
5744
- name: Run build
5845
run: opam exec -- make build

src/request/js/nodejs/nodejs_common.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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
2727
end
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 =
7575
let 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

Comments
 (0)