I'm using the requests library in NodeJS to pull images from a website, and save them to disk. The website I'm pulling from, instead of 404-ing, redirects to the homepage, and serves the HTML. Is there a proper way of detecting this change/redirect without parsing the body of the response?
You can check the Content-Type
sent by the server in response.headers['content-type']
.