Fixing code review issues.

This commit is contained in:
ali.ibrahim 2016-10-25 12:41:01 +02:00
parent 0c44d19249
commit 61278f9ace
14 changed files with 106 additions and 112 deletions

View file

@ -3,18 +3,15 @@
const url = require('url')
const {EventEmitter} = require('events')
const util = require('util')
const Readable = require('stream').Readable
const binding = process.atomBinding('net')
const {net, Net} = binding
const {URLRequest} = net
const {Readable} = require('stream')
const {app} = require('electron')
const {net, Net} = process.atomBinding('net')
const {URLRequest} = net
Object.setPrototypeOf(Net.prototype, EventEmitter.prototype)
Object.setPrototypeOf(URLRequest.prototype, EventEmitter.prototype)
let kSupportedProtocols = new Set()
kSupportedProtocols.add('http:')
kSupportedProtocols.add('https:')
const kSupportedProtocols = new Set(['http:', 'https:'])
class IncomingMessage extends Readable {
constructor (urlRequest) {
@ -82,8 +79,8 @@ class IncomingMessage extends Readable {
}
URLRequest.prototype._emitRequestEvent = function (async, ...rest) {
if (async) {
URLRequest.prototype._emitRequestEvent = function (isAsync, ...rest) {
if (isAsync) {
process.nextTick(() => {
this.clientRequest.emit.apply(this.clientRequest, rest)
})
@ -92,8 +89,8 @@ URLRequest.prototype._emitRequestEvent = function (async, ...rest) {
}
}
URLRequest.prototype._emitResponseEvent = function (async, ...rest) {
if (async) {
URLRequest.prototype._emitResponseEvent = function (isAsync, ...rest) {
if (isAsync) {
process.nextTick(() => {
this._response.emit.apply(this._response, rest)
})
@ -175,9 +172,7 @@ class ClientRequest extends EventEmitter {
this.extraHeaders = {}
if (options.headers) {
const keys = Object.keys(options.headers)
for (let i = 0, l = keys.length; i < l; i++) {
const key = keys[i]
for (let key in options.headers) {
this.setHeader(key, options.headers[key])
}
}