简体   繁体   English

Node.JS Express - 原始 HTTP 请求

[英]Node.JS Express - Original HTTP Request

Is there a way in Express to get the original HTTP request as it was prior to being parsed? Express 中有没有办法像解析之前一样获取原始 HTTP 请求?

Like this:像这样:

GET / HTTP/1.1
Host: www.example.com
User-Agent: Mozilla/5.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: en-GB,en;q=0.5
Accept-Encoding: gzip, deflate, br
Connection: keep-alive

See link below for a basic implementation which I used to implement a store-and-forward proxy.有关我用来实现存储转发代理的基本实现,请参见下面的链接。 This uses the raw Node.js http module, but express.js extends the req/res objects, so it should be fully compatible:这使用原始 Node.js http模块,但 express.js 扩展了 req/res 对象,因此它应该完全兼容:
https://github.com/rkaw92/edi-broker-poc/blob/df7d643ed07e8004eb7a93fcde580549872fe757/src/httpUtils.ts#L50 https://github.com/rkaw92/edi-broker-poc/blob/df7d643ed07e8004eb7a93fcde580549872fe757/src/httpUtils.ts#L50

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM