Skip to content

Commit 50d3bcd

Browse files
committed
fix(use): Set request readable encoding to utf-8
Closes #118
1 parent 94100d6 commit 50d3bcd

File tree

4 files changed

+4
-0
lines changed

4 files changed

+4
-0
lines changed

src/use/express.ts

+1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ function toRequest(
132132
}
133133
return new Promise<string>((resolve) => {
134134
let body = '';
135+
req.setEncoding('utf-8');
135136
req.on('data', (chunk) => (body += chunk));
136137
req.on('end', () => resolve(body));
137138
});

src/use/http.ts

+1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ function toRequest(
142142
body: () =>
143143
new Promise<string>((resolve) => {
144144
let body = '';
145+
req.setEncoding('utf-8');
145146
req.on('data', (chunk) => (body += chunk));
146147
req.on('end', () => resolve(body));
147148
}),

src/use/http2.ts

+1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ function toRequest(
176176
body: () =>
177177
new Promise<string>((resolve) => {
178178
let body = '';
179+
req.setEncoding('utf-8');
179180
req.on('data', (chunk) => (body += chunk));
180181
req.on('end', () => resolve(body));
181182
}),

src/use/koa.ts

+1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ export function createHandler<Context extends OperationContext = undefined>(
126126
}
127127
return new Promise<string>((resolve) => {
128128
let body = '';
129+
ctx.req.setEncoding('utf-8');
129130
ctx.req.on('data', (chunk) => (body += chunk));
130131
ctx.req.on('end', () => resolve(body));
131132
});

0 commit comments

Comments
 (0)