docs: http protocol handlers can access headers (#15431)
* test: check http protocol handlers can access headers * docs: http protocol handlers can access headers
This commit is contained in:
		
					parent
					
						
							
								59ee2859a7
							
						
					
				
			
			
				commit
				
					
						bae652f46d
					
				
			
		
					 2 changed files with 25 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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', () => {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue