diff --git a/docs/api/protocol.md b/docs/api/protocol.md index 4d19869cea..5220066143 100644 --- a/docs/api/protocol.md +++ b/docs/api/protocol.md @@ -169,6 +169,7 @@ should be called with either a `String` or an object that has the `data`, * `handler` Function * `request` Object * `url` String + * `headers` Object * `referrer` String * `method` String * `uploadData` [UploadData[]](structures/upload-data.md) @@ -329,6 +330,7 @@ which sends a `Buffer` as a response. * `handler` Function * `request` Object * `url` String + * `headers` Object * `referrer` String * `method` String * `uploadData` [UploadData[]](structures/upload-data.md) diff --git a/spec/api-protocol-spec.js b/spec/api-protocol-spec.js index 630d380797..55ec69e925 100644 --- a/spec/api-protocol-spec.js +++ b/spec/api-protocol-spec.js @@ -475,6 +475,19 @@ describe('protocol module', () => { }) }) }) + + it('can access request headers', (done) => { + const handler = (request) => { + assert.ok('headers' in request) + done() + } + protocol.registerHttpProtocol(protocolName, handler, () => { + $.ajax({ + url: protocolName + '://fake-host', + cache: false + }) + }) + }) }) describe('protocol.registerStreamProtocol', () => { @@ -897,6 +910,16 @@ describe('protocol module', () => { }) }) }) + + it('can access request headers', (done) => { + const handler = (request) => { + assert.ok('headers' in request) + done() + } + protocol.interceptHttpProtocol('http', handler, () => { + fetch('http://fake-host') + }) + }) }) describe('protocol.interceptStreamProtocol', () => {