Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readme 文档中操作请求的demo 有误 #32

Open
GoodEnoughL opened this issue May 6, 2023 · 1 comment
Open

Readme 文档中操作请求的demo 有误 #32

GoodEnoughL opened this issue May 6, 2023 · 1 comment

Comments

@GoodEnoughL
Copy link

GoodEnoughL commented May 6, 2023

No description provided.

@GoodEnoughL
Copy link
Author

GoodEnoughL commented May 6, 2023

readme文档中操作请求章节的代码为

exports.handleRequest = async (ctx, request) => {
	// ctx.fullUrl 可以获取请求url
	// ctx.headers 可以获取请求头
	// ctx.options 里面包含一些特殊的请求头字段,分别可以获取一些额外信息,如请设置的规则等
	// ctx.method 获取和设置请求方法
	// ctx.req
	// ctx.res
	const { req, res } = ctx;
	const client = request((svrRes) => {
		res.writeHead(svrRes.statusCode, svrRes.headers);
		svrRes.pipe(res);
		// try {
			// const body = await ctx.getStreamBuffer(svrRes);
			// delete svrRes.headers['content-encoding'];
			// res.writeHead(svrRes.statusCode, svrRes.headers);
			// res.end(body);
		// } catch (err) {}
	});
	req.pipe(client);
};

与该章节内容不符合,且与demo 图片内容不符合,可能造成误解,望大佬修复下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant