mirror of
https://github.com/lush2020/edgetunnel.git
synced 2026-03-24 17:18:25 +08:00
support http client
This commit is contained in:
@@ -43,4 +43,23 @@ function rawHTTPPackage(req: IncomingMessage) {
|
||||
return concatStreams([[rawHttpHeader], req]);
|
||||
}
|
||||
|
||||
export { concatStreams, rawHTTPPackage, rawHTTPHeader };
|
||||
async function* deplay(ms) {
|
||||
yield await new Promise((res, reject) => {
|
||||
setTimeout(() => res(''), ms);
|
||||
});
|
||||
}
|
||||
|
||||
// delay few ms for
|
||||
// // request.body readablestream end casue socket to be end, this will casue socket send FIN package early
|
||||
// and casue deno can't get TCP pcakge.
|
||||
function rawHTTPPackageWithDelay(req: IncomingMessage) {
|
||||
const rawHttpHeader = rawHTTPHeader(req);
|
||||
return concatStreams([[rawHttpHeader], req, deplay(500)]);
|
||||
}
|
||||
|
||||
export {
|
||||
concatStreams,
|
||||
rawHTTPPackage,
|
||||
rawHTTPHeader,
|
||||
rawHTTPPackageWithDelay,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user