Browse Source

Revert "add http2 support back"

This reverts commit b1a979d698.
master
Guillermo Rauch 9 years ago
parent
commit
1bd1b56ce3
  1. 11
      lib/agent.js
  2. 1
      package.json

11
lib/agent.js

@ -1,6 +1,4 @@
import http2 from 'spdy';
import fetch from 'node-fetch'; import fetch from 'node-fetch';
import { parse } from 'url';
/** /**
* Returns a `fetch` version with a similar * Returns a `fetch` version with a similar
@ -16,16 +14,17 @@ import { parse } from 'url';
export default class Agent { export default class Agent {
constructor (url, { debug } = {}) { constructor (url, { debug } = {}) {
this._url = url; this._url = url;
this._host = parse(url).host;
this._debug = debug; this._debug = debug;
this._initAgent(); this._initAgent();
} }
_initAgent () { _initAgent () {
this._agent = http2.createAgent({ /*
this._agent = https.createAgent({
host: this._host, host: this._host,
port: 443 port: 443
}).once('error', (err) => this._onError(err)); }).once('error', (err) => this._onError(err));
*/
} }
_onError (err) { _onError (err) {
@ -44,7 +43,7 @@ export default class Agent {
} }
const { body } = opts; const { body } = opts;
opts.agent = this._agent; // opts.agent = this._agent;
if (body && 'object' === typeof body && 'function' !== typeof body.pipe) { if (body && 'object' === typeof body && 'function' !== typeof body.pipe) {
opts.headers['Content-Type'] = 'application/json'; opts.headers['Content-Type'] = 'application/json';
@ -60,6 +59,6 @@ export default class Agent {
close () { close () {
if (this._debug) console.log('> [debug] closing agent'); if (this._debug) console.log('> [debug] closing agent');
return this._agent.close(); // return this._agent.close();
} }
} }

1
package.json

@ -31,7 +31,6 @@
"socket.io-client": "1.4.5", "socket.io-client": "1.4.5",
"split-array": "1.0.1", "split-array": "1.0.1",
"text-table": "0.2.0", "text-table": "0.2.0",
"spdy": "3.3.3",
"email-validator": "1.0.4", "email-validator": "1.0.4",
"email-prompt": "0.1.4" "email-prompt": "0.1.4"
}, },

Loading…
Cancel
Save