X Tutup
Skip to content

Commit bae652f

Browse files
dsanders11codebytere
authored andcommitted
docs: http protocol handlers can access headers (electron#15431)
* test: check http protocol handlers can access headers * docs: http protocol handlers can access headers
1 parent 59ee285 commit bae652f

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

docs/api/protocol.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ should be called with either a `String` or an object that has the `data`,
169169
* `handler` Function
170170
* `request` Object
171171
* `url` String
172+
* `headers` Object
172173
* `referrer` String
173174
* `method` String
174175
* `uploadData` [UploadData[]](structures/upload-data.md)
@@ -329,6 +330,7 @@ which sends a `Buffer` as a response.
329330
* `handler` Function
330331
* `request` Object
331332
* `url` String
333+
* `headers` Object
332334
* `referrer` String
333335
* `method` String
334336
* `uploadData` [UploadData[]](structures/upload-data.md)

spec/api-protocol-spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,19 @@ describe('protocol module', () => {
475475
})
476476
})
477477
})
478+
479+
it('can access request headers', (done) => {
480+
const handler = (request) => {
481+
assert.ok('headers' in request)
482+
done()
483+
}
484+
protocol.registerHttpProtocol(protocolName, handler, () => {
485+
$.ajax({
486+
url: protocolName + '://fake-host',
487+
cache: false
488+
})
489+
})
490+
})
478491
})
479492

480493
describe('protocol.registerStreamProtocol', () => {
@@ -897,6 +910,16 @@ describe('protocol module', () => {
897910
})
898911
})
899912
})
913+
914+
it('can access request headers', (done) => {
915+
const handler = (request) => {
916+
assert.ok('headers' in request)
917+
done()
918+
}
919+
protocol.interceptHttpProtocol('http', handler, () => {
920+
fetch('http://fake-host')
921+
})
922+
})
900923
})
901924

902925
describe('protocol.interceptStreamProtocol', () => {

0 commit comments

Comments
 (0)
X Tutup