File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ class Environment;
1616#define DEFAULT_MAX_HEADER_LIST_PAIRS 128u
1717#define DEFAULT_MAX_HEADER_LENGTH 8192
1818
19+ constexpr size_t kMaxInternalizedHeaderNameLength = 64 ;
20+
1921#define HTTP_SPECIAL_HEADERS (V ) \
2022 V (STATUS , " :status" ) \
2123 V (METHOD , " :method" ) \
@@ -432,7 +434,7 @@ class NgRcBufPointer : public MemoryRetainer {
432434 return v8::String::Empty (env->isolate ());
433435 }
434436
435- if (ptr.IsInternalizable () && len < 64 ) {
437+ if (ptr.IsInternalizable () && len < kMaxInternalizedHeaderNameLength ) {
436438 v8::MaybeLocal<v8::String> ret = GetInternalizedString (env, ptr);
437439 ptr.reset ();
438440 return ret;
Original file line number Diff line number Diff line change 2828#include " llhttp.h"
2929#include " memory_tracker-inl.h"
3030#include " node_external_reference.h"
31+ #include " node_http_common.h"
3132#include " stream_base-inl.h"
3233#include " v8.h"
3334
@@ -235,14 +236,15 @@ struct StringPtr {
235236 }
236237
237238 Local<String> ToInternalizedString (Environment* env) const {
238- if (size_ != 0 ) {
239+ // Only internalize short names to avoid pressuring the string table.
240+ if (size_ != 0 && size_ < kMaxInternalizedHeaderNameLength ) {
239241 return String::NewFromOneByte (env->isolate (),
240242 reinterpret_cast <const uint8_t *>(str_),
241243 NewStringType::kInternalized ,
242244 size_)
243245 .ToLocalChecked ();
244246 }
245- return String::Empty (env-> isolate () );
247+ return ToString (env);
246248 }
247249
248250 // Strip trailing OWS (SPC or HTAB) from string.
You can’t perform that action at this time.
0 commit comments