关于这个问题:在 Nodejs/Protractor 中将 Cookie 从一个请求传输/传递到另一个请求 https://stackoverflow.com/questions/42078780/transfer-pass-cookies-from-one-request-to-another-in-nodejs-protractor
我又得到了一个。我如何查看我通过nodejs执行的完整请求(标头+正文)?
是的,您可以...您可以从完整响应正文访问完整的请求 -response.request
我有一个通用的完整响应结构,如下所示
IncomingMessage
ReadableState
headers(ResponseHeaders)
rawHeaders
request - //This is what you need
headers
body
body(Response Body)
可以通过如下代码访问
var request = require("request");
var options = { method: 'POST',
url: 'http://1.1.1.1/login',
headers:
{ 'cache-control': 'no-cache',
'content-type': 'application/json' },
body: { email: '[email protected] /cdn-cgi/l/email-protection', password: 'junk@123' },
json: true };
request(options, function (error, response, body) {
if (error) throw new Error(error);
// This will give you complete request
console.log(response.request);
//This gives you the headers from Request
console.log(response.request.headers);
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)