| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4caf536 commit 441175c
20 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -62,7 +62,7 @@ const { | |||
| 62 | 62 | } = require('timers'); | |
| 63 | 63 | ||
| 64 | 64 | const { ShutdownWrap, WriteWrap } = process.binding('stream_wrap'); | |
| 65 | - const { constants } = binding; | ||
| 65 | + const { constants, nameForErrorCode } = binding; | ||
| 66 | 66 | ||
| 67 | 67 | const NETServer = net.Server; | |
| 68 | 68 | const TLSServer = tls.Server; | |
@@ -1841,7 +1841,8 @@ class Http2Stream extends Duplex { | |||
| 1841 | 1841 | // abort and is already covered by aborted event, also allows more | |
| 1842 | 1842 | // seamless compatibility with http1 | |
| 1843 | 1843 | if (err == null && code !== NGHTTP2_NO_ERROR && code !== NGHTTP2_CANCEL) | |
| 1844 | - err = new errors.Error('ERR_HTTP2_STREAM_ERROR', code); | ||
| 1844 | + err = new errors.Error('ERR_HTTP2_STREAM_ERROR', | ||
| 1845 | + nameForErrorCode[code] || code); | ||
| 1845 | 1846 | ||
| 1846 | 1847 | this[kSession] = undefined; | |
| 1847 | 1848 | this[kHandle] = undefined; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2857,29 +2857,39 @@ void Initialize(Local<Object> target, | |||
| 2857 | 2857 | session->GetFunction()).FromJust(); | |
| 2858 | 2858 | ||
| 2859 | 2859 | Local<Object> constants = Object::New(isolate); | |
| 2860 | - NODE_DEFINE_CONSTANT(constants, NGHTTP2_SESSION_SERVER); | ||
| 2861 | - NODE_DEFINE_CONSTANT(constants, NGHTTP2_SESSION_CLIENT); | ||
| 2862 | - NODE_DEFINE_CONSTANT(constants, NGHTTP2_STREAM_STATE_IDLE); | ||
| 2863 | - NODE_DEFINE_CONSTANT(constants, NGHTTP2_STREAM_STATE_OPEN); | ||
| 2864 | - NODE_DEFINE_CONSTANT(constants, NGHTTP2_STREAM_STATE_RESERVED_LOCAL); | ||
| 2865 | - NODE_DEFINE_CONSTANT(constants, NGHTTP2_STREAM_STATE_RESERVED_REMOTE); | ||
| 2866 | - NODE_DEFINE_CONSTANT(constants, NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL); | ||
| 2867 | - NODE_DEFINE_CONSTANT(constants, NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE); | ||
| 2868 | - NODE_DEFINE_CONSTANT(constants, NGHTTP2_STREAM_STATE_CLOSED); | ||
| 2869 | - NODE_DEFINE_CONSTANT(constants, NGHTTP2_NO_ERROR); | ||
| 2870 | - NODE_DEFINE_CONSTANT(constants, NGHTTP2_PROTOCOL_ERROR); | ||
| 2871 | - NODE_DEFINE_CONSTANT(constants, NGHTTP2_INTERNAL_ERROR); | ||
| 2872 | - NODE_DEFINE_CONSTANT(constants, NGHTTP2_FLOW_CONTROL_ERROR); | ||
| 2873 | - NODE_DEFINE_CONSTANT(constants, NGHTTP2_SETTINGS_TIMEOUT); | ||
| 2874 | - NODE_DEFINE_CONSTANT(constants, NGHTTP2_STREAM_CLOSED); | ||
| 2875 | - NODE_DEFINE_CONSTANT(constants, NGHTTP2_FRAME_SIZE_ERROR); | ||
| 2876 | - NODE_DEFINE_CONSTANT(constants, NGHTTP2_REFUSED_STREAM); | ||
| 2877 | - NODE_DEFINE_CONSTANT(constants, NGHTTP2_CANCEL); | ||
| 2878 | - NODE_DEFINE_CONSTANT(constants, NGHTTP2_COMPRESSION_ERROR); | ||
| 2879 | - NODE_DEFINE_CONSTANT(constants, NGHTTP2_CONNECT_ERROR); | ||
| 2880 | - NODE_DEFINE_CONSTANT(constants, NGHTTP2_ENHANCE_YOUR_CALM); | ||
| 2881 | - NODE_DEFINE_CONSTANT(constants, NGHTTP2_INADEQUATE_SECURITY); | ||
| 2882 | - NODE_DEFINE_CONSTANT(constants, NGHTTP2_HTTP_1_1_REQUIRED); | ||
| 2860 | + Local<Array> name_for_error_code = Array::New(isolate); | ||
| 2861 | + | ||
| 2862 | + #define NODE_NGHTTP2_ERROR_CODES(V) \ | ||
| 2863 | + V(NGHTTP2_SESSION_SERVER); \ | ||
| 2864 | + V(NGHTTP2_SESSION_CLIENT); \ | ||
| 2865 | + V(NGHTTP2_STREAM_STATE_IDLE); \ | ||
| 2866 | + V(NGHTTP2_STREAM_STATE_OPEN); \ | ||
| 2867 | + V(NGHTTP2_STREAM_STATE_RESERVED_LOCAL); \ | ||
| 2868 | + V(NGHTTP2_STREAM_STATE_RESERVED_REMOTE); \ | ||
| 2869 | + V(NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL); \ | ||
| 2870 | + V(NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE); \ | ||
| 2871 | + V(NGHTTP2_STREAM_STATE_CLOSED); \ | ||
| 2872 | + V(NGHTTP2_NO_ERROR); \ | ||
| 2873 | + V(NGHTTP2_PROTOCOL_ERROR); \ | ||
| 2874 | + V(NGHTTP2_INTERNAL_ERROR); \ | ||
| 2875 | + V(NGHTTP2_FLOW_CONTROL_ERROR); \ | ||
| 2876 | + V(NGHTTP2_SETTINGS_TIMEOUT); \ | ||
| 2877 | + V(NGHTTP2_STREAM_CLOSED); \ | ||
| 2878 | + V(NGHTTP2_FRAME_SIZE_ERROR); \ | ||
| 2879 | + V(NGHTTP2_REFUSED_STREAM); \ | ||
| 2880 | + V(NGHTTP2_CANCEL); \ | ||
| 2881 | + V(NGHTTP2_COMPRESSION_ERROR); \ | ||
| 2882 | + V(NGHTTP2_CONNECT_ERROR); \ | ||
| 2883 | + V(NGHTTP2_ENHANCE_YOUR_CALM); \ | ||
| 2884 | + V(NGHTTP2_INADEQUATE_SECURITY); \ | ||
| 2885 | + V(NGHTTP2_HTTP_1_1_REQUIRED); \ | ||
| 2886 | + | ||
| 2887 | + #define V(name) \ | ||
| 2888 | + NODE_DEFINE_CONSTANT(constants, name); \ | ||
| 2889 | + name_for_error_code->Set(static_cast<int>(name), \ | ||
| 2890 | + FIXED_ONE_BYTE_STRING(isolate, #name)); | ||
| 2891 | + NODE_NGHTTP2_ERROR_CODES(V) | ||
| 2892 | + #undef V | ||
| 2883 | 2893 | ||
| 2884 | 2894 | NODE_DEFINE_HIDDEN_CONSTANT(constants, NGHTTP2_HCAT_REQUEST); | |
| 2885 | 2895 | NODE_DEFINE_HIDDEN_CONSTANT(constants, NGHTTP2_HCAT_RESPONSE); | |
@@ -2944,6 +2954,9 @@ HTTP_STATUS_CODES(V) | |||
| 2944 | 2954 | target->Set(context, | |
| 2945 | 2955 | FIXED_ONE_BYTE_STRING(isolate, "constants"), | |
| 2946 | 2956 | constants).FromJust(); | |
| 2957 | + target->Set(context, | ||
| 2958 | + FIXED_ONE_BYTE_STRING(isolate, "nameForErrorCode"), | ||
| 2959 | + name_for_error_code).FromJust(); | ||
| 2947 | 2960 | } | |
| 2948 | 2961 | } // namespace http2 | |
| 2949 | 2962 | } // namespace node | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -47,7 +47,7 @@ server.listen(0, common.mustCall(() => { | |||
| 47 | 47 | req.on('error', common.expectsError({ | |
| 48 | 48 | code: 'ERR_HTTP2_STREAM_ERROR', | |
| 49 | 49 | type: Error, | |
| 50 | - message: `Stream closed with error code ${closeCode}` | ||
| 50 | + message: 'Stream closed with error code NGHTTP2_PROTOCOL_ERROR' | ||
| 51 | 51 | })); | |
| 52 | 52 | ||
| 53 | 53 | req.on('response', common.mustCall()); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,7 +18,8 @@ server.on('stream', (stream) => { | |||
| 18 | 18 | // system specific timings. | |
| 19 | 19 | stream.on('error', (err) => { | |
| 20 | 20 | assert.strictEqual(err.code, 'ERR_HTTP2_STREAM_ERROR'); | |
| 21 | - assert.strictEqual(err.message, 'Stream closed with error code 2'); | ||
| 21 | + assert.strictEqual(err.message, | ||
| 22 | + 'Stream closed with error code NGHTTP2_INTERNAL_ERROR'); | ||
| 22 | 23 | }); | |
| 23 | 24 | stream.respond(); | |
| 24 | 25 | stream.end(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,7 +27,7 @@ server.listen(0, common.mustCall(() => { | |||
| 27 | 27 | req.on('error', common.expectsError({ | |
| 28 | 28 | code: 'ERR_HTTP2_STREAM_ERROR', | |
| 29 | 29 | type: Error, | |
| 30 | - message: 'Stream closed with error code 1' | ||
| 30 | + message: 'Stream closed with error code NGHTTP2_PROTOCOL_ERROR' | ||
| 31 | 31 | })); | |
| 32 | 32 | req.on('close', common.mustCall(() => countdown.dec())); | |
| 33 | 33 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -58,7 +58,7 @@ server.listen(0, common.mustCall(() => { | |||
| 58 | 58 | req.on('error', common.expectsError({ | |
| 59 | 59 | code: 'ERR_HTTP2_STREAM_ERROR', | |
| 60 | 60 | type: Error, | |
| 61 | - message: 'Stream closed with error code 2' | ||
| 61 | + message: 'Stream closed with error code NGHTTP2_INTERNAL_ERROR' | ||
| 62 | 62 | })); | |
| 63 | 63 | req.on('close', common.mustCall(() => countdown.dec())); | |
| 64 | 64 | ||
@@ -73,7 +73,7 @@ server.listen(0, common.mustCall(() => { | |||
| 73 | 73 | req.on('error', common.expectsError({ | |
| 74 | 74 | code: 'ERR_HTTP2_STREAM_ERROR', | |
| 75 | 75 | type: Error, | |
| 76 | - message: 'Stream closed with error code 2' | ||
| 76 | + message: 'Stream closed with error code NGHTTP2_INTERNAL_ERROR' | ||
| 77 | 77 | })); | |
| 78 | 78 | req.on('close', common.mustCall(() => countdown.dec())); | |
| 79 | 79 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -72,7 +72,7 @@ function runTest(test) { | |||
| 72 | 72 | req.on('error', common.expectsError({ | |
| 73 | 73 | code: 'ERR_HTTP2_STREAM_ERROR', | |
| 74 | 74 | type: Error, | |
| 75 | - message: 'Stream closed with error code 2' | ||
| 75 | + message: 'Stream closed with error code NGHTTP2_INTERNAL_ERROR' | ||
| 76 | 76 | })); | |
| 77 | 77 | ||
| 78 | 78 | req.on('close', common.mustCall(() => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -50,7 +50,7 @@ server.listen(0, common.mustCall(() => { | |||
| 50 | 50 | req.on('error', common.expectsError({ | |
| 51 | 51 | code: 'ERR_HTTP2_STREAM_ERROR', | |
| 52 | 52 | type: Error, | |
| 53 | - message: 'Stream closed with error code 7' | ||
| 53 | + message: 'Stream closed with error code NGHTTP2_REFUSED_STREAM' | ||
| 54 | 54 | })); | |
| 55 | 55 | } | |
| 56 | 56 | })); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -63,7 +63,7 @@ server.on('stream', (stream) => { | |||
| 63 | 63 | stream.on('error', common.expectsError({ | |
| 64 | 64 | code: 'ERR_HTTP2_STREAM_ERROR', | |
| 65 | 65 | type: Error, | |
| 66 | - message: 'Stream closed with error code 3' | ||
| 66 | + message: 'Stream closed with error code NGHTTP2_FLOW_CONTROL_ERROR' | ||
| 67 | 67 | })); | |
| 68 | 68 | stream.on('close', common.mustCall(() => { | |
| 69 | 69 | server.close(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -69,7 +69,7 @@ server.on('stream', (stream) => { | |||
| 69 | 69 | stream.on('error', common.expectsError({ | |
| 70 | 70 | code: 'ERR_HTTP2_STREAM_ERROR', | |
| 71 | 71 | type: Error, | |
| 72 | - message: 'Stream closed with error code 3' | ||
| 72 | + message: 'Stream closed with error code NGHTTP2_FLOW_CONTROL_ERROR' | ||
| 73 | 73 | })); | |
| 74 | 74 | stream.on('close', common.mustCall(() => { | |
| 75 | 75 | server.close(common.mustCall()); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments