node-http2: http2 agent doesn't work with request module
Hi,
I’m trying to use the http2 agent with the request module. Running
var request = require("request");
var https = require("https");
var myHttp1Agent = new https.Agent({ca:ca});
request({url:"https://foo.testing/", agent:myHttp1Agent},function(error, response, body){
console.log("request with http1 agent");
console.log(error,body);
});
works fine but with the http2 version
var request = require("request");
var http2 = require("http2");
var myHttp2Agent = new http2.Agent({ca:ca});
request({url:"https://foo.testing/", agent:myHttp2Agent},function(error, response, body){
console.log("request with http2 agent");
console.log(error,body);
});
I get an exception:
_http_client.js:137
self.agent.addRequest(self, options);
^
TypeError: self.agent.addRequest is not a function
at new ClientRequest (_http_client.js:137:16)
at Object.exports.request (http.js:31:10)
at Object.exports.request (https.js:181:15)
at Request.start (/home/node/app/node_modules/request/request.js:746:30)
at Request.end (/home/node/app/node_modules/request/request.js:1357:10)
at end (/home/node/app/node_modules/request/request.js:574:14)
at Immediate._onImmediate (/home/node/app/node_modules/request/request.js:588:7)
at processImmediate [as _immediateCallback] (timers.js:383:17)
As far as I understood, http2 is supposed to be a drop in replacement for the http(s) module. So, is this a bug?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (4 by maintainers)
Commits related to this issue
- Fix bug when calling request with agent option Fix https://github.com/molnarg/node-http2/issues/174 Before the internal https.Agent of http2.Agent were left to the agent from the request option (h... — committed to felicienfrancois/node-http2 by felicienfrancois 8 years ago
- Fix http2 agent doesn't work with request module Fix #174 — committed to felicienfrancois/node-http2 by felicienfrancois 8 years ago
- Fix http2 agent doesn't work with request module Fix #174 — committed to mcmanus/node-http2 by felicienfrancois 8 years ago
@danpantry The pull request is not yet merged. This project seems no longer maintained by its owners (is it?). In the meantime you can switch to my fork : https://github.com/felicienfrancois/node-http2 which includes the fix (among others) in your package.json: