Skip to content

Commit

Permalink
http2: expose http2 by default, add NODE_NO_HTTP2
Browse files Browse the repository at this point in the history
Make `--expose-http2` a non-op,
Expose http2 by default.
Add `NODE_NO_HTTP2=1` to suppress http2

PR-URL: #15685
Reviewed-By: Myles Borins <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
  • Loading branch information
jasnell authored and evanlucas committed Oct 23, 2017
1 parent e34509e commit 57ab6e2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
7 changes: 7 additions & 0 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,13 @@ added: v7.5.0

When set to `1`, process warnings are silenced.

### `NODE_NO_HTTP2=1`
<!-- YAML
added: REPLACEME
-->

When set to `1`, the `http2` module is suppressed.

### `NODE_OPTIONS=options...`
<!-- YAML
added: v8.0.0
Expand Down
3 changes: 0 additions & 3 deletions doc/api/http2.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ can be accessed using:
const http2 = require('http2');
```

*Note*: Node.js must be launched with the `--expose-http2` command line flag
in order to use the `'http2'` module.

## Core API

The Core API provides a low-level interface designed specifically around
Expand Down
8 changes: 4 additions & 4 deletions doc/node.1
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,6 @@ Emit pending deprecation warnings.
.BR \-\-no\-warnings
Silence all process warnings (including deprecations).

.TP
.BR \-\-expose\-http2
Enable the experimental `'http2'` module.

.TP
.BR \-\-napi\-modules
Enable loading native modules compiled with the ABI-stable Node.js API (N-API)
Expand Down Expand Up @@ -280,6 +276,10 @@ with small\-icu support.
.BR NODE_NO_WARNINGS =\fI1\fR
When set to \fI1\fR, process warnings are silenced.

.TP
.BR NODE_NO_HTTP2 =\fI1\fR
When set to \fI1\fR, the http2 module is suppressed.

.TP
.BR NODE_OPTIONS =\fIoptions...\fR
A space-separated list of command line options. \fBoptions...\fR are interpreted
Expand Down
16 changes: 11 additions & 5 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ std::string config_warning_file; // NOLINT(runtime/string)
// that is used by lib/internal/bootstrap_node.js
bool config_expose_internals = false;

// Set in node.cc by ParseArgs when --expose-http2 is used.
bool config_expose_http2 = false;
// Set to false in node.cc when NODE_NO_HTTP2=1 is used.
bool config_expose_http2 = true;

bool v8_initialized = false;

Expand Down Expand Up @@ -3830,7 +3830,6 @@ static void PrintHelp() {
" --abort-on-uncaught-exception\n"
" aborting instead of exiting causes a\n"
" core file to be generated for analysis\n"
" --expose-http2 enable experimental HTTP2 support\n"
" --trace-warnings show stack traces on process warnings\n"
" --redirect-warnings=file\n"
" write warnings to file instead of\n"
Expand Down Expand Up @@ -3894,7 +3893,8 @@ static void PrintHelp() {
#endif
#endif
"NODE_NO_WARNINGS set to 1 to silence process warnings\n"
#if !defined(NODE_WITHOUT_NODE_OPTIONS)
"NODE_NO_HTTP2 set to 1 to suppress the http2 module\n"
#if !defined(NODE_WITHOUT_NODE_OPTIONS)
"NODE_OPTIONS set CLI options in the environment\n"
" via a space-separated list\n"
#endif
Expand Down Expand Up @@ -4173,7 +4173,7 @@ static void ParseArgs(int* argc,
config_expose_internals = true;
} else if (strcmp(arg, "--expose-http2") == 0 ||
strcmp(arg, "--expose_http2") == 0) {
config_expose_http2 = true;
// Intentional non-op
} else if (strcmp(arg, "-") == 0) {
break;
} else if (strcmp(arg, "--") == 0) {
Expand Down Expand Up @@ -4550,6 +4550,12 @@ void Init(int* argc,
SafeGetenv("NODE_PENDING_DEPRECATION", &text) && text[0] == '1';
}

{
std::string text;
config_expose_http2 =
!(SafeGetenv("NODE_NO_HTTP2", &text) && text[0] == '1');
}

// Allow for environment set preserving symlinks.
{
std::string text;
Expand Down

0 comments on commit 57ab6e2

Please sign in to comment.