GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: small modification to NgHeader · nodejs/node@354ff4f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_http_common-inl.h
    • node_http_common.h
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node_http_common-inl.h‎

Copy file name to clipboardExpand all lines: src/node_http_common-inl.h
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ size_t GetServerMaxHeaderPairs(size_t max_header_pairs) {
7676
return std::max(max_header_pairs, min_header_pairs);
7777
}
7878

79+
template <typename allocator_t>
80+
std::string NgHeaderBase<allocator_t>::ToString() const {
81+
std::string ret = name();
82+
ret += " = ";
83+
ret += value();
84+
return ret;
85+
}
86+
7987
template <typename T>
8088
bool NgHeader<T>::IsZeroLength(
8189
NgHeader<T>::rcbuf_t* name,
@@ -132,6 +140,12 @@ NgHeader<T>::NgHeader(NgHeader<T>&& other) noexcept
132140
other.env_ = nullptr;
133141
}
134142

143+
template <typename T>
144+
void NgHeader<T>::MemoryInfo(MemoryTracker* tracker) const {
145+
tracker->TrackField("name", name_);
146+
tracker->TrackField("value", value_);
147+
}
148+
135149
template <typename T>
136150
v8::MaybeLocal<v8::String> NgHeader<T>::GetName(
137151
NgHeader<T>::allocator_t* allocator) const {
Collapse file

‎src/node_http_common.h‎

Copy file name to clipboardExpand all lines: src/node_http_common.h
+19-17Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,16 @@ class NgRcBufPointer : public MemoryRetainer {
453453
bool internalizable_ = false;
454454
};
455455

456+
template <typename allocator_t>
457+
struct NgHeaderBase : public MemoryRetainer {
458+
virtual v8::MaybeLocal<v8::String> GetName(allocator_t* allocator) const = 0;
459+
virtual v8::MaybeLocal<v8::String> GetValue(allocator_t* allocator) const = 0;
460+
virtual std::string name() const = 0;
461+
virtual std::string value() const = 0;
462+
virtual size_t length() const = 0;
463+
virtual std::string ToString() const;
464+
};
465+
456466
// The ng libraries use nearly identical structs to represent
457467
// received http headers. The NgHeader class wraps those in a
458468
// consistent way and allows converting the name and value to
@@ -461,7 +471,7 @@ class NgRcBufPointer : public MemoryRetainer {
461471
// memory tracking, and implementation of static utility functions.
462472
// See Http2HeaderTraits in node_http2.h for an example.
463473
template <typename T>
464-
class NgHeader : public MemoryRetainer {
474+
class NgHeader final : public NgHeaderBase<typename T::allocator_t> {
465475
public:
466476
typedef typename T::rcbufferpointer_t rcbufferpointer_t;
467477
typedef typename T::rcbufferpointer_t::rcbuf_t rcbuf_t;
@@ -487,28 +497,20 @@ class NgHeader : public MemoryRetainer {
487497
// object to the v8 string. Once the v8 string is garbage collected,
488498
// the reference counter will be decremented.
489499

490-
inline v8::MaybeLocal<v8::String> GetName(allocator_t* allocator) const;
491-
inline v8::MaybeLocal<v8::String> GetValue(allocator_t* allocator) const;
500+
inline v8::MaybeLocal<v8::String> GetName(
501+
allocator_t* allocator) const override;
502+
inline v8::MaybeLocal<v8::String> GetValue(
503+
allocator_t* allocator) const override;
492504

493-
inline std::string name() const;
494-
inline std::string value() const;
495-
inline size_t length() const;
505+
inline std::string name() const override;
506+
inline std::string value() const override;
507+
inline size_t length() const override;
496508

497-
void MemoryInfo(MemoryTracker* tracker) const override {
498-
tracker->TrackField("name", name_);
499-
tracker->TrackField("value", value_);
500-
}
509+
void MemoryInfo(MemoryTracker* tracker) const override;
501510

502511
SET_MEMORY_INFO_NAME(NgHeader)
503512
SET_SELF_SIZE(NgHeader)
504513

505-
std::string ToString() const {
506-
std::string ret = name();
507-
ret += " = ";
508-
ret += value();
509-
return ret;
510-
}
511-
512514
private:
513515
Environment* env_;
514516
rcbufferpointer_t name_;

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.