mirror of
https://github.com/lush2020/edgetunnel.git
synced 2026-03-23 16:38:34 +08:00
32 lines
641 B
JavaScript
32 lines
641 B
JavaScript
import * as undici from 'undici';
|
|
import { pipeline, Readable, Writable } from 'node:stream';
|
|
|
|
pipeline(
|
|
new Readable({
|
|
read() {
|
|
this.push(Buffer.from('undici'));
|
|
this.push(null);
|
|
},
|
|
}),
|
|
undici.pipeline(
|
|
'http://localhost:1082',
|
|
{
|
|
method: 'POST',
|
|
},
|
|
({ statusCode, headers, body }) => {
|
|
console.log(`response received ${statusCode}`);
|
|
console.log('headers', headers);
|
|
console.log('headers', body);
|
|
return body;
|
|
}
|
|
),
|
|
// new Writable({
|
|
// write(chunk) {
|
|
// console.log(chunk.toString());
|
|
// },
|
|
// }),
|
|
(error) => {
|
|
console.log(error);
|
|
}
|
|
);
|