Browse Source

http: make http2 the default, legacy backend is available with --use-http1

Fixes #1441.
v0.7.4-release
Ben Noordhuis 14 years ago
parent
commit
38f948a373
  1. 8
      Makefile
  2. 10
      src/node.cc
  3. 6
      src/node.js
  4. 6
      tools/test.py

8
Makefile

@ -35,8 +35,8 @@ uninstall:
test: all
python tools/test.py --mode=release simple message
test-http2: all
python tools/test.py --mode=release --use-http2 simple message
test-http1: all
python tools/test.py --mode=release --use-http1 simple message
test-valgrind: all
python tools/test.py --mode=release --valgrind simple message
@ -44,8 +44,8 @@ test-valgrind: all
test-all: all
python tools/test.py --mode=debug,release
test-all-http2: all
python tools/test.py --mode=debug,release --use-http2
test-all-http1: all
python tools/test.py --mode=debug,release --use-http1
test-all-valgrind: all
python tools/test.py --mode=debug,release --valgrind

10
src/node.cc

@ -139,7 +139,7 @@ static bool use_uv = true;
#endif
// disabled by default for now
static bool use_http2 = false;
static bool use_http1 = false;
#ifdef OPENSSL_NPN_NEGOTIATED
static bool use_npn = true;
@ -2040,7 +2040,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("http1"), Boolean::New(use_http1));
obj->Set(String::NewSymbol("ipv6"), True()); // TODO ping libuv
obj->Set(String::NewSymbol("tls_npn"), Boolean::New(use_npn));
obj->Set(String::NewSymbol("tls_sni"), Boolean::New(use_sni));
@ -2285,7 +2285,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"
" --use-http1 use the legacy http library\n"
"\n"
"Enviromental variables:\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")) {
use_uv = true;
argv[i] = const_cast<char*>("");
} else if (!strcmp(arg, "--use-http2")) {
use_http2 = true;
} else if (!strcmp(arg, "--use-http1")) {
use_http1 = true;
argv[i] = const_cast<char*>("");
} else if (strcmp(arg, "--version") == 0 || strcmp(arg, "-v") == 0) {
printf("%s\n", NODE_VERSION);

6
src/node.js

@ -32,7 +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;
if (process.env.NODE_USE_HTTP1 == '1') process.features.http1 = true;
EventEmitter = NativeModule.require('events').EventEmitter;
process.__proto__ = EventEmitter.prototype;
@ -403,10 +403,10 @@
function translateId(id) {
switch (id) {
case 'http':
return process.features.http2 ? 'http2' : 'http';
return process.features.http1 ? 'http' : 'http2';
case 'https':
return process.features.http2 ? 'https2' : 'https';
return process.features.http1 ? 'https' : 'https2';
case 'net':
return process.features.uv ? 'net_uv' : 'net_legacy';

6
tools/test.py

@ -1148,7 +1148,7 @@ def BuildOptions():
result.add_option("--simulator", help="Run tests with architecture simulator",
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")
result.add_option("--valgrind", help="Run tests through valgrind",
default=False, action="store_true")
@ -1309,9 +1309,9 @@ def Main():
buildspace = dirname(shell)
processor = GetSpecialCommandProcessor(options.special_command)
if options.use_http2:
if options.use_http1:
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)
context = Context(workspace,

Loading…
Cancel
Save