| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 234a505 commit 0556f54
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,7 +27,7 @@ const { | |||
| 27 | 27 | } = primordials; | |
| 28 | 28 | const { setImmediate } = require('timers'); | |
| 29 | 29 | ||
| 30 | - const { methods, HTTPParser } = internalBinding('http_parser'); | ||
| 30 | + const { methods, allMethods, HTTPParser } = internalBinding('http_parser'); | ||
| 31 | 31 | const { getOptionValue } = require('internal/options'); | |
| 32 | 32 | const insecureHTTPParser = getOptionValue('--insecure-http-parser'); | |
| 33 | 33 | ||
@@ -108,7 +108,7 @@ function parserOnHeadersComplete(versionMajor, versionMinor, headers, method, | |||
| 108 | 108 | ||
| 109 | 109 | if (typeof method === 'number') { | |
| 110 | 110 | // server only | |
| 111 | - incoming.method = methods[method]; | ||
| 111 | + incoming.method = allMethods[method]; | ||
| 112 | 112 | } else { | |
| 113 | 113 | // client only | |
| 114 | 114 | incoming.statusCode = statusCode; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1305,7 +1305,9 @@ void InitializeHttpParser(Local<Object> target, | |||
| 1305 | 1305 | Integer::NewFromUnsigned(env->isolate(), kLenientAll)); | |
| 1306 | 1306 | ||
| 1307 | 1307 | Local<Array> methods = Array::New(env->isolate()); | |
| 1308 | + Local<Array> all_methods = Array::New(env->isolate()); | ||
| 1308 | 1309 | size_t method_index = -1; | |
| 1310 | + size_t all_method_index = -1; | ||
| 1309 | 1311 | #define V(num, name, string) \ | |
| 1310 | 1312 | methods \ | |
| 1311 | 1313 | ->Set(env->context(), \ | |
@@ -1314,9 +1316,23 @@ void InitializeHttpParser(Local<Object> target, | |||
| 1314 | 1316 | .Check(); | |
| 1315 | 1317 | HTTP_METHOD_MAP(V) | |
| 1316 | 1318 | #undef V | |
| 1319 | + #define V(num, name, string) \ | ||
| 1320 | + all_methods \ | ||
| 1321 | + ->Set(env->context(), \ | ||
| 1322 | + ++all_method_index, \ | ||
| 1323 | + FIXED_ONE_BYTE_STRING(env->isolate(), #string)) \ | ||
| 1324 | + .Check(); | ||
| 1325 | + HTTP_ALL_METHOD_MAP(V) | ||
| 1326 | + #undef V | ||
| 1327 | + | ||
| 1317 | 1328 | target->Set(env->context(), | |
| 1318 | 1329 | FIXED_ONE_BYTE_STRING(env->isolate(), "methods"), | |
| 1319 | 1330 | methods).Check(); | |
| 1331 | + target | ||
| 1332 | + ->Set(env->context(), | ||
| 1333 | + FIXED_ONE_BYTE_STRING(env->isolate(), "allMethods"), | ||
| 1334 | + all_methods) | ||
| 1335 | + .Check(); | ||
| 1320 | 1336 | ||
| 1321 | 1337 | t->Inherit(AsyncWrap::GetConstructorTemplate(env)); | |
| 1322 | 1338 | 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