apify / got-scraping

HTTP client made for scraping based on got.
423 stars 32 forks source link

Preserve header names #59

Open Cooya opened 2 years ago

Cooya commented 2 years ago

I am sending requests to a server which does not respect HTTP specification specifying that headers should be case-insensitive. The problem is that with got-scraping, a header named "MyHeader" will be renamed "Myheader"...

How can I send a header whose name will be kept untouched ?

Cooya commented 2 years ago

I tried using a hook without success :

let { gotScraping } = require('got-scraping');

gotScraping = gotScraping.extend({
  hooks: {
    beforeRequest: [
      options => {
        options.headers['myheader'] = options.headers['MyHeader'];
        delete options.headers['myheader'];
      }
    ]
  }
});