Comments (3)
// 设置客户端响应的http头部
Object.keys(realRes.headers).forEach(function(key) {
res.setHeader(key, realRes.headers[key]);
});
// 设置客户端响应状态码
res.writeHead(realRes.statusCode);
// 通过pipe的方式把真正的服务器响应内容转发给客户端
realRes.pipe(res);
如果不手动设置 status ,header 。只使用 realRes.pipe(res), 客户端无法获取真正服务器返回的status ,header
from https-mitm-proxy-handbook.
好的,多谢,我试过确实是这样的,但是不太明白为什么realRes.pipe(res)不能把realRes的所有内容都流入到res呢,statusCode不也是从realRes取出来又塞进去res的吗
from https-mitm-proxy-handbook.
@leotian ,可能一般场景都是只要内容,所以这么设计的吧。比如把响应内容直接写入某个文件,这个时候把status和header也写进去了,那就有点奇怪。用来做转发的需求是比较少的。
stackoverflow 上关于这点的问题答案:https://stackoverflow.com/a/29199616
from https-mitm-proxy-handbook.
Related Issues (10)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from https-mitm-proxy-handbook.