MontFerret/ferret

How to capture HEADERS from response? (filename)

lorico opened this issue · 2 comments

Hi,
I am trying to use Ferret in order to download a csv file from some url.
I would like to capture the HEADERS from the get request, and specially the "Content-disposition" (ex: "attachment; filename=somefilename.csv") as it will contain the filename (and I need that to do further treatment on that file).
=> How do I capture the headers from the response after my operation/"doc" object below ?

LET doc = DOCUMENT("https://someurl?Format=CSV", {
    driver: "cdp",
    userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36",
})

Thanks a lot for helping me on the right direction :)

Hello! I think you can use doc.headers:

let doc = document(url, {
  userAgent: "some UA",
  headers: inputHeaders
})

let headerValue = doc.headers["headerName"]?.value

Hope it will help!

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.