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

Fix Electron throwing HTTP trailers are not supported error #598

Merged
merged 8 commits into from
Aug 31, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions source/request-as-event-emitter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
'use strict';
/* istanbul ignore next: webpack only */
const r = ({x: require})['yx'.slice(1)];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only used in one place, so just put it inline with the function call at line 50.

/* istanbul ignore next: compatibility reason */
const URLGlobal = typeof URL === 'undefined' ? require('url').URL : URL; // TODO: Use the `URL` global when targeting Node.js 10
const EventEmitter = require('events');
Expand Down Expand Up @@ -47,14 +49,14 @@ module.exports = options => {

/* istanbul ignore next: electron.net is broken */
if (options.useElectronNet && process.versions.electron) {
const electron = require('electron');
const electron = r('electron');
fn = electron.net || electron.remote.net;
}

let timings;
const cacheableRequest = new CacheableRequest(fn.request, options.cache);
const cacheReq = cacheableRequest(options, response => {
// Fixes https://github.com/electron/electron/blob/cbb460d47628a7a146adf4419ed48550a98b2923/lib/browser/api/net.js#L59-L65
/* istanbul ignore next: fixes https://github.com/electron/electron/blob/cbb460d47628a7a146adf4419ed48550a98b2923/lib/browser/api/net.js#L59-L65 */
if (options.useElectronNet) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment with a link to the Electron issue this fixes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'll do.

response = new Proxy(response, {
get: (target, name) => {
Expand Down