0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00

http: add --use-http2 switch

This commit is contained in:
Ben Noordhuis 2011-07-26 00:39:57 +02:00
parent 2ed23314c3
commit 0082ef271e
2 changed files with 14 additions and 0 deletions

View File

@ -139,6 +139,8 @@ static bool use_uv = false;
static bool use_uv = true;
#endif
// disabled by default for now
static bool use_http2 = false;
// Buffer for getpwnam_r(), getgrpam_r() and other misc callers; keep this
// scoped at file-level rather than method-level to avoid excess stack usage.
@ -2018,6 +2020,7 @@ static Handle<Object> GetFeatures() {
Local<Object> obj = Object::New();
obj->Set(String::NewSymbol("uv"), Boolean::New(use_uv));
obj->Set(String::NewSymbol("http2"), Boolean::New(use_http2));
obj->Set(String::NewSymbol("ipv6"), True()); // TODO ping libuv
obj->Set(String::NewSymbol("tls"),
Boolean::New(get_builtin_module("crypto") != NULL));
@ -2256,6 +2259,7 @@ static void PrintHelp() {
" --vars print various compiled-in variables\n"
" --max-stack-size=val set max v8 stack size (bytes)\n"
" --use-uv use the libuv backend\n"
" --use-http2 use the new and improved http library\n"
"\n"
"Enviromental variables:\n"
"NODE_PATH ':'-separated list of directories\n"
@ -2280,6 +2284,9 @@ static void ParseArgs(int argc, char **argv) {
} else if (!strcmp(arg, "--use-uv")) {
use_uv = true;
argv[i] = const_cast<char*>("");
} else if (!strcmp(arg, "--use-http2")) {
use_http2 = true;
argv[i] = const_cast<char*>("");
} else if (strcmp(arg, "--version") == 0 || strcmp(arg, "-v") == 0) {
printf("%s\n", NODE_VERSION);
exit(0);

View File

@ -32,6 +32,7 @@
function startup() {
if (process.env.NODE_USE_UV == '1') process.features.uv = true;
if (process.env.NODE_USE_HTTP2 == '1') process.features.http2 = true;
EventEmitter = NativeModule.require('events').EventEmitter;
process.__proto__ = EventEmitter.prototype;
@ -387,6 +388,12 @@
// backend.
function translateId(id) {
switch (id) {
case 'http':
return process.features.http2 ? 'http2' : 'http';
case 'https':
return process.features.http2 ? 'https2' : 'https';
case 'net':
return process.features.uv ? 'net_uv' : 'net_legacy';