提交 9702675d 编写于 作者: J Joao Moreno

remove asJson header restriction

上级 2996b94e
......@@ -165,13 +165,15 @@ export function asJson<T>(context: IRequestContext): TPromise<T> {
return c(null);
}
if (!/application\/json/.test(context.res.headers['content-type'])) {
return e('Response doesn\'t appear to be JSON');
}
const buffer: string[] = [];
context.stream.on('data', (d: string) => buffer.push(d));
context.stream.on('end', () => c(JSON.parse(buffer.join(''))));
context.stream.on('end', () => {
try {
c(JSON.parse(buffer.join('')));
} catch (err) {
e(err);
}
});
context.stream.on('error', e);
});
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册