| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b0e6a6b commit ad9c4bd
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,7 +28,7 @@ const { | |||
| 28 | 28 | } = primordials; | |
| 29 | 29 | const { setImmediate } = require('timers'); | |
| 30 | 30 | ||
| 31 | - const { methods, HTTPParser } = internalBinding('http_parser'); | ||
| 31 | + const { methods, allMethods, HTTPParser } = internalBinding('http_parser'); | ||
| 32 | 32 | const { getOptionValue } = require('internal/options'); | |
| 33 | 33 | const insecureHTTPParser = getOptionValue('--insecure-http-parser'); | |
| 34 | 34 | ||
@@ -109,7 +109,7 @@ function parserOnHeadersComplete(versionMajor, versionMinor, headers, method, | |||
| 109 | 109 | ||
| 110 | 110 | if (typeof method === 'number') { | |
| 111 | 111 | // server only | |
| 112 | - incoming.method = methods[method]; | ||
| 112 | + incoming.method = allMethods[method]; | ||
| 113 | 113 | } else { | |
| 114 | 114 | // client only | |
| 115 | 115 | incoming.statusCode = statusCode; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1304,7 +1304,9 @@ void InitializeHttpParser(Local<Object> target, | |||
| 1304 | 1304 | Integer::NewFromUnsigned(env->isolate(), kLenientAll)); | |
| 1305 | 1305 | ||
| 1306 | 1306 | Local<Array> methods = Array::New(env->isolate()); | |
| 1307 | + Local<Array> all_methods = Array::New(env->isolate()); | ||
| 1307 | 1308 | size_t method_index = -1; | |
| 1309 | + size_t all_method_index = -1; | ||
| 1308 | 1310 | #define V(num, name, string) \ | |
| 1309 | 1311 | methods \ | |
| 1310 | 1312 | ->Set(env->context(), \ | |
@@ -1313,9 +1315,23 @@ void InitializeHttpParser(Local<Object> target, | |||
| 1313 | 1315 | .Check(); | |
| 1314 | 1316 | HTTP_METHOD_MAP(V) | |
| 1315 | 1317 | #undef V | |
| 1318 | + #define V(num, name, string) \ | ||
| 1319 | + all_methods \ | ||
| 1320 | + ->Set(env->context(), \ | ||
| 1321 | + ++all_method_index, \ | ||
| 1322 | + FIXED_ONE_BYTE_STRING(env->isolate(), #string)) \ | ||
| 1323 | + .Check(); | ||
| 1324 | + HTTP_ALL_METHOD_MAP(V) | ||
| 1325 | + #undef V | ||
| 1326 | + | ||
| 1316 | 1327 | target->Set(env->context(), | |
| 1317 | 1328 | FIXED_ONE_BYTE_STRING(env->isolate(), "methods"), | |
| 1318 | 1329 | methods).Check(); | |
| 1330 | + target | ||
| 1331 | + ->Set(env->context(), | ||
| 1332 | + FIXED_ONE_BYTE_STRING(env->isolate(), "allMethods"), | ||
| 1333 | + all_methods) | ||
| 1334 | + .Check(); | ||
| 1319 | 1335 | ||
| 1320 | 1336 | t->Inherit(AsyncWrap::GetConstructorTemplate(env)); | |
| 1321 | 1337 | SetProtoMethod(isolate, t, "close", Parser::Close); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,27 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const { strictEqual } = require('assert'); | ||
| 5 | + const { createServer, request } = require('http'); | ||
| 6 | + | ||
| 7 | + const server = createServer(common.mustCall((req, res) => { | ||
| 8 | + strictEqual(req.method, 'QUERY'); | ||
| 9 | + res.end('OK'); | ||
| 10 | + })); | ||
| 11 | + | ||
| 12 | + server.listen(0, common.mustCall(() => { | ||
| 13 | + const req = request({ port: server.address().port, method: 'QUERY' }, common.mustCall((res) => { | ||
| 14 | + strictEqual(res.statusCode, 200); | ||
| 15 | + | ||
| 16 | + let buffer = ''; | ||
| 17 | + res.setEncoding('utf-8'); | ||
| 18 | + | ||
| 19 | + res.on('data', (c) => buffer += c); | ||
| 20 | + res.on('end', common.mustCall(() => { | ||
| 21 | + strictEqual(buffer, 'OK'); | ||
| 22 | + server.close(); | ||
| 23 | + })); | ||
| 24 | + })); | ||
| 25 | + | ||
| 26 | + req.end(); | ||
| 27 | + })); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments