Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: responseHeaders should be Record<string, string[]> #21730

Merged
merged 1 commit into from Jan 12, 2020

Conversation

miniak
Copy link
Contributor

@miniak miniak commented Jan 10, 2020

Description of Change

The values in responseHeaders are received as arrays as can be seen by running this code:

session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
  console.log('onHeadersReceived', details)
  callback({ responseHeaders: details.responseHeaders });
})

session.defaultSession.webRequest.onResponseStarted((details) => {
  console.log('onResponseStarted', details)    
})

session.defaultSession.webRequest.onCompleted((details) => {
  console.log('onCompleted', details)    
})

outputs

onHeadersReceived {
  id: 1,
  url: 'https://www.example.com/',
  method: 'GET',
  timestamp: 1578667512665.565,
  resourceType: 'mainFrame',
  fromCache: false,
  statusLine: 'HTTP/1.1 200',
  statusCode: 200,
  responseHeaders: {
    'accept-ranges': [ 'bytes' ],
    'cache-control': [ 'max-age=604800' ],
    'content-encoding': [ 'gzip' ],
    'content-length': [ '648' ],
    'content-type': [ 'text/html; charset=UTF-8' ],
    date: [ 'Fri, 10 Jan 2020 14:34:06 GMT' ],
    etag: [ '"3147526947"' ],
    expires: [ 'Fri, 17 Jan 2020 14:34:06 GMT' ],
    'last-modified': [ 'Thu, 17 Oct 2019 07:18:26 GMT' ],
    server: [ 'ECS (bsa/EB20)' ],
    status: [ '200' ],
    vary: [ 'Accept-Encoding' ],
    'x-cache': [ 'HIT' ]
  },
  webContentsId: 1,
  referrer: ''
}

onResponseStarted {
  id: 1,
  url: 'https://www.example.com/',
  method: 'GET',
  timestamp: 1578667512682.504,
  resourceType: 'mainFrame',
  ip: '2606:2800:220:1:248:1893:25c8:1946',
  fromCache: true,
  statusLine: 'HTTP/1.1 200',
  statusCode: 200,
  responseHeaders: {
    'accept-ranges': [ 'bytes' ],
    'cache-control': [ 'max-age=604800' ],
    'content-encoding': [ 'gzip' ],
    'content-length': [ '648' ],
    'content-type': [ 'text/html; charset=UTF-8' ],
    date: [ 'Fri, 10 Jan 2020 14:34:06 GMT' ],
    etag: [ '"3147526947"' ],
    expires: [ 'Fri, 17 Jan 2020 14:34:06 GMT' ],
    'last-modified': [ 'Thu, 17 Oct 2019 07:18:26 GMT' ],
    server: [ 'ECS (bsa/EB20)' ],
    status: [ '200' ],
    vary: [ 'Accept-Encoding' ],
    'x-cache': [ 'HIT' ]
  },
  webContentsId: 1,
  referrer: ''
}

onCompleted {
  id: 1,
  url: 'https://www.example.com/',
  method: 'GET',
  timestamp: 1578667512683.189,
  resourceType: 'mainFrame',
  ip: '2606:2800:220:1:248:1893:25c8:1946',
  fromCache: true,
  statusLine: 'HTTP/1.1 200',
  statusCode: 200,
  responseHeaders: {
    'accept-ranges': [ 'bytes' ],
    'cache-control': [ 'max-age=604800' ],
    'content-encoding': [ 'gzip' ],
    'content-length': [ '648' ],
    'content-type': [ 'text/html; charset=UTF-8' ],
    date: [ 'Fri, 10 Jan 2020 14:34:06 GMT' ],
    etag: [ '"3147526947"' ],
    expires: [ 'Fri, 17 Jan 2020 14:34:06 GMT' ],
    'last-modified': [ 'Thu, 17 Oct 2019 07:18:26 GMT' ],
    server: [ 'ECS (bsa/EB20)' ],
    status: [ '200' ],
    vary: [ 'Accept-Encoding' ],
    'x-cache': [ 'HIT' ]
  },
  webContentsId: 1,
  referrer: '',
  error: 'net::OK'
}

Follow-up to #18302

Checklist

Release Notes

Notes: Fixed responseHeaders types in electron.d.ts

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jan 10, 2020
@miniak miniak self-assigned this Jan 10, 2020
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Jan 11, 2020
@codebytere codebytere merged commit c0bde4b into master Jan 12, 2020
@release-clerk
Copy link

release-clerk bot commented Jan 12, 2020

Release Notes Persisted

Fixed responseHeaders types in electron.d.ts

@trop
Copy link
Contributor

trop bot commented Jan 12, 2020

I have automatically backported this PR to "7-1-x", please check out #21742

@trop trop bot removed the target/7-1-x label Jan 12, 2020
@trop
Copy link
Contributor

trop bot commented Jan 12, 2020

I have automatically backported this PR to "8-x-y", please check out #21743

@sofianguy sofianguy added this to Fixed in 8.0.0-beta.6 in 8.2.x Jan 14, 2020
@sofianguy sofianguy added this to Fixed in 7.1.9 in 7.2.x Jan 14, 2020
ghost pushed a commit to wireapp/wire-desktop that referenced this pull request Feb 5, 2020
An error in the typings happened a few weeks ago and the docs has been fixed accordingly electron/electron#21730
ghost pushed a commit to wireapp/wire-desktop that referenced this pull request Feb 5, 2020
An error in the typings happened a few weeks ago and the docs has been fixed accordingly electron/electron#21730
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
7.2.x
Fixed in 7.1.9
8.2.x
Fixed in 8.0.0-beta.6
Development

Successfully merging this pull request may close these issues.

None yet

5 participants