Skip to content

Commit

Permalink
Fix: make it a real BitArray
Browse files Browse the repository at this point in the history
  • Loading branch information
Kero van Gelder authored and lpil committed Mar 7, 2024
1 parent c420036 commit a5a8479
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/ffi.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Ok, Error, List } from "./gleam.mjs";
import { Ok, Error, List, toBitArray } from "./gleam.mjs";
import { to_string as uri_to_string } from "../gleam_stdlib/gleam/uri.mjs";
import { method_to_string } from "../gleam_http/gleam/http.mjs";
import { to_uri } from "../gleam_http/gleam/http/request.mjs";
Expand Down Expand Up @@ -45,11 +45,11 @@ function make_headers(headersList) {
export async function read_bytes_body(response) {
let body;
try {
body = await response.body.text();
body = await response.body.arrayBuffer()
} catch (error) {
return new Error(new UnableToReadBody());
}
return new Ok(response.withFields({ body }));
return new Ok(response.withFields({ body: toBitArray(new Uint8Array(body)) }));
}

export async function read_text_body(response) {
Expand Down
2 changes: 1 addition & 1 deletion test/gleam_fetch_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn request_test() {
let assert 200 = resp.status
let assert Ok("application/json") =
response.get_header(resp, "content-type")
// TODO let assert <<123, 34, 109, 101, 115, 115, 97, 103, 101, 34, 58, 34, 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 34, 125>> = resp.body
let assert <<123, 34, 109, 101, 115, 115, 97, 103, 101, 34, 58, 34, 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 34, 125>> = resp.body
promise.resolve(Ok(Nil))
})
}
Expand Down

0 comments on commit a5a8479

Please sign in to comment.