CA
Crawlee & Apify•2y ago
eastern-cyan

Inspect the request headers

Is there any way to inspect/log the request headers after goint to a page, just like what you can see in the Developer Console? I tried to look at ctx.response?.request().allHeaders(), but it is always empty.
postNavigationHooks: [
async (ctx) => {
log.info("Request finished", {
requestUrl: ctx.request.url,
statusCode: ctx.response?.status() || null,
requestHeaders: ctx.response?.request().allHeaders(),
});
},
],
postNavigationHooks: [
async (ctx) => {
log.info("Request finished", {
requestUrl: ctx.request.url,
statusCode: ctx.response?.status() || null,
requestHeaders: ctx.response?.request().allHeaders(),
});
},
],
No description
4 Replies
MEE6
MEE6•2y ago
@toan just advanced to level 1! Thanks for your contributions! 🎉
Alexey Udovydchenko
Alexey Udovydchenko•2y ago
request is "yours" data, what you get is ctx.response and as I remeber there is also ctx.response.request
eastern-cyan
eastern-cyanOP•2y ago
Yes I understand that. That's what I'm trying to do with ctx.response?.request().allHeaders() , getting the request headers from the response.
Alexey Udovydchenko
Alexey Udovydchenko•2y ago
what about the rest of properties? i.e. ?.headers[] I used response headers under cheerio for some additional functionality but it was pretty long time ago, do not remember details

Did you find this page helpful?