Skip to content

Commit

Permalink
http: make http2 the default, legacy backend is available with --use-…
Browse files Browse the repository at this point in the history
…http1

Fixes nodejs#1441.
  • Loading branch information
bnoordhuis committed Aug 2, 2011
1 parent 48dcb90 commit 38f948a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ 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

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
Expand Down
10 changes: 5 additions & 5 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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"
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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';
Expand Down
6 changes: 3 additions & 3 deletions tools/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 38f948a

Please sign in to comment.