http.request(url.parse(x))

http2.js

protocols object to store defaults for http and https, and use as a switch for supported protocols.
options.hostname > options.host > 'localhost'
if I have an options.auth element and I do not have an Authorization header, I do basic auth.
http.request collapses to new ClientRequest since the defaults are handled by the protocol object

test-http-url.parse*

Fixes #1390

Conflicts:

	lib/http2.js
This commit is contained in:
seebees
2011-10-14 17:10:49 -07:00
committed by koichik
parent be4576de7a
commit 005d607aed
10 changed files with 453 additions and 3 deletions

View File

@@ -68,12 +68,16 @@ exports.globalAgent = globalAgent;
exports.Agent = Agent;
exports.request = function(options, cb) {
if (options.protocol && options.protocol !== 'https:') {
throw new Error('Protocol:' + options.protocol + ' not supported.');
}
if (options.agent === undefined) {
options.agent = globalAgent;
}
options.createConnection = createConnection;
options.defaultPort = options.defaultPort || 443;
return http.request(options, cb);
return new http.ClientRequest(options, cb);
};
exports.get = function(options, cb) {