http: make http2 the default, legacy backend is available with --use-http1
Fixes #1441.
This commit is contained in:
parent
48dcb905f6
commit
38f948a373
8
Makefile
8
Makefile
@ -35,8 +35,8 @@ uninstall:
|
|||||||
test: all
|
test: all
|
||||||
python tools/test.py --mode=release simple message
|
python tools/test.py --mode=release simple message
|
||||||
|
|
||||||
test-http2: all
|
test-http1: all
|
||||||
python tools/test.py --mode=release --use-http2 simple message
|
python tools/test.py --mode=release --use-http1 simple message
|
||||||
|
|
||||||
test-valgrind: all
|
test-valgrind: all
|
||||||
python tools/test.py --mode=release --valgrind simple message
|
python tools/test.py --mode=release --valgrind simple message
|
||||||
@ -44,8 +44,8 @@ test-valgrind: all
|
|||||||
test-all: all
|
test-all: all
|
||||||
python tools/test.py --mode=debug,release
|
python tools/test.py --mode=debug,release
|
||||||
|
|
||||||
test-all-http2: all
|
test-all-http1: all
|
||||||
python tools/test.py --mode=debug,release --use-http2
|
python tools/test.py --mode=debug,release --use-http1
|
||||||
|
|
||||||
test-all-valgrind: all
|
test-all-valgrind: all
|
||||||
python tools/test.py --mode=debug,release --valgrind
|
python tools/test.py --mode=debug,release --valgrind
|
||||||
|
10
src/node.cc
10
src/node.cc
@ -139,7 +139,7 @@ static bool use_uv = true;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// disabled by default for now
|
// disabled by default for now
|
||||||
static bool use_http2 = false;
|
static bool use_http1 = false;
|
||||||
|
|
||||||
#ifdef OPENSSL_NPN_NEGOTIATED
|
#ifdef OPENSSL_NPN_NEGOTIATED
|
||||||
static bool use_npn = true;
|
static bool use_npn = true;
|
||||||
@ -2040,7 +2040,7 @@ static Handle<Object> GetFeatures() {
|
|||||||
|
|
||||||
Local<Object> obj = Object::New();
|
Local<Object> obj = Object::New();
|
||||||
obj->Set(String::NewSymbol("uv"), Boolean::New(use_uv));
|
obj->Set(String::NewSymbol("uv"), Boolean::New(use_uv));
|
||||||
obj->Set(String::NewSymbol("http2"), Boolean::New(use_http2));
|
obj->Set(String::NewSymbol("http1"), Boolean::New(use_http1));
|
||||||
obj->Set(String::NewSymbol("ipv6"), True()); // TODO ping libuv
|
obj->Set(String::NewSymbol("ipv6"), True()); // TODO ping libuv
|
||||||
obj->Set(String::NewSymbol("tls_npn"), Boolean::New(use_npn));
|
obj->Set(String::NewSymbol("tls_npn"), Boolean::New(use_npn));
|
||||||
obj->Set(String::NewSymbol("tls_sni"), Boolean::New(use_sni));
|
obj->Set(String::NewSymbol("tls_sni"), Boolean::New(use_sni));
|
||||||
@ -2285,7 +2285,7 @@ static void PrintHelp() {
|
|||||||
" --vars print various compiled-in variables\n"
|
" --vars print various compiled-in variables\n"
|
||||||
" --max-stack-size=val set max v8 stack size (bytes)\n"
|
" --max-stack-size=val set max v8 stack size (bytes)\n"
|
||||||
" --use-uv use the libuv backend\n"
|
" --use-uv use the libuv backend\n"
|
||||||
" --use-http2 use the new and improved http library\n"
|
" --use-http1 use the legacy http library\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Enviromental variables:\n"
|
"Enviromental variables:\n"
|
||||||
"NODE_PATH ':'-separated list of directories\n"
|
"NODE_PATH ':'-separated list of directories\n"
|
||||||
@ -2310,8 +2310,8 @@ static void ParseArgs(int argc, char **argv) {
|
|||||||
} else if (!strcmp(arg, "--use-uv")) {
|
} else if (!strcmp(arg, "--use-uv")) {
|
||||||
use_uv = true;
|
use_uv = true;
|
||||||
argv[i] = const_cast<char*>("");
|
argv[i] = const_cast<char*>("");
|
||||||
} else if (!strcmp(arg, "--use-http2")) {
|
} else if (!strcmp(arg, "--use-http1")) {
|
||||||
use_http2 = true;
|
use_http1 = true;
|
||||||
argv[i] = const_cast<char*>("");
|
argv[i] = const_cast<char*>("");
|
||||||
} else if (strcmp(arg, "--version") == 0 || strcmp(arg, "-v") == 0) {
|
} else if (strcmp(arg, "--version") == 0 || strcmp(arg, "-v") == 0) {
|
||||||
printf("%s\n", NODE_VERSION);
|
printf("%s\n", NODE_VERSION);
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
function startup() {
|
function startup() {
|
||||||
|
|
||||||
if (process.env.NODE_USE_UV == '1') process.features.uv = true;
|
if (process.env.NODE_USE_UV == '1') process.features.uv = true;
|
||||||
if (process.env.NODE_USE_HTTP2 == '1') process.features.http2 = true;
|
if (process.env.NODE_USE_HTTP1 == '1') process.features.http1 = true;
|
||||||
|
|
||||||
EventEmitter = NativeModule.require('events').EventEmitter;
|
EventEmitter = NativeModule.require('events').EventEmitter;
|
||||||
process.__proto__ = EventEmitter.prototype;
|
process.__proto__ = EventEmitter.prototype;
|
||||||
@ -403,10 +403,10 @@
|
|||||||
function translateId(id) {
|
function translateId(id) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 'http':
|
case 'http':
|
||||||
return process.features.http2 ? 'http2' : 'http';
|
return process.features.http1 ? 'http' : 'http2';
|
||||||
|
|
||||||
case 'https':
|
case 'https':
|
||||||
return process.features.http2 ? 'https2' : 'https';
|
return process.features.http1 ? 'https' : 'https2';
|
||||||
|
|
||||||
case 'net':
|
case 'net':
|
||||||
return process.features.uv ? 'net_uv' : 'net_legacy';
|
return process.features.uv ? 'net_uv' : 'net_legacy';
|
||||||
|
@ -1148,7 +1148,7 @@ def BuildOptions():
|
|||||||
result.add_option("--simulator", help="Run tests with architecture simulator",
|
result.add_option("--simulator", help="Run tests with architecture simulator",
|
||||||
default='none')
|
default='none')
|
||||||
result.add_option("--special-command", default=None)
|
result.add_option("--special-command", default=None)
|
||||||
result.add_option("--use-http2", help="Pass --use-http2 switch to node",
|
result.add_option("--use-http1", help="Pass --use-http1 switch to node",
|
||||||
default=False, action="store_true")
|
default=False, action="store_true")
|
||||||
result.add_option("--valgrind", help="Run tests through valgrind",
|
result.add_option("--valgrind", help="Run tests through valgrind",
|
||||||
default=False, action="store_true")
|
default=False, action="store_true")
|
||||||
@ -1309,9 +1309,9 @@ def Main():
|
|||||||
buildspace = dirname(shell)
|
buildspace = dirname(shell)
|
||||||
|
|
||||||
processor = GetSpecialCommandProcessor(options.special_command)
|
processor = GetSpecialCommandProcessor(options.special_command)
|
||||||
if options.use_http2:
|
if options.use_http1:
|
||||||
def wrap(processor):
|
def wrap(processor):
|
||||||
return lambda args: processor(args[:1] + ['--use-http2'] + args[1:])
|
return lambda args: processor(args[:1] + ['--use-http1'] + args[1:])
|
||||||
processor = wrap(processor)
|
processor = wrap(processor)
|
||||||
|
|
||||||
context = Context(workspace,
|
context = Context(workspace,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user