Skip to content

Commit e8bad38

Browse files
authored
http (internal): Optimization for text responses of Fetch API (#3373)
- http (internal): Optimization for text responses of Fetch API - reformat
1 parent efee000 commit e8bad38

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

airframe-http/.js/src/main/scala/wvlet/airframe/http/client/JSFetchChannel.scala

+8-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,14 @@ class JSFetchChannel(serverAddress: ServerAddress, config: HttpClientConfig) ext
8484
header.add(h(0), h(1))
8585
}
8686
r = r.withHeader(header.result())
87-
resp.arrayBuffer().toFuture.map { body =>
88-
r.withContent(new Int8Array(body).toArray)
87+
if (r.isContentTypeJson) {
88+
resp.text().toFuture.map { body =>
89+
r.withContent(body)
90+
}
91+
} else {
92+
resp.arrayBuffer().toFuture.map { body =>
93+
r.withContent(new Int8Array(body).toArray)
94+
}
8995
}
9096
}
9197

0 commit comments

Comments
 (0)