youtube / spfjs

A lightweight JS framework for fast navigation and page updates from YouTube
https://youtube.github.io/spfjs/
MIT License
2.24k stars 147 forks source link

Allow custom headers to be sent with requests #391

Closed nicksay closed 8 years ago

nicksay commented 8 years ago

In addition to the standard SPF headers (e.g. X-SPF-Referer), this change allows the client to specify custom headers to send with requests.

These headers will be set globally using the request-headers config:

spf.init({
  'request-headers': {
    'X-Custom-Header-One': 'Custom Value One',
    'X-Custom-Header-Two': 'Custom Value Two'
  }
})

Or, they may be set on a per-request basis for API calls using options:

spf.navigate(url, {
  headers: {
    'X-Custom-Header-One': 'Custom Value One',
    'X-Custom-Header-Two': 'Custom Value Two'
  }
})

For now, gate the feature using the experimental-request-headers config and the experimental_headers option.

Progress on #390

nicksay commented 8 years ago

@youtube/spfjs PTAL

awbraunstein commented 8 years ago

lgtm