Skip to content

Commit

Permalink
docs: http protocol handlers can access headers (electron#15431)
Browse files Browse the repository at this point in the history
* test: check http protocol handlers can access headers

* docs: http protocol handlers can access headers
  • Loading branch information
dsanders11 authored and codebytere committed Oct 30, 2018
1 parent 59ee285 commit bae652f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/api/protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
23 changes: 23 additions & 0 deletions spec/api-protocol-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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', () => {
Expand Down

0 comments on commit bae652f

Please sign in to comment.