Bitcoin Core 31.99.0
P2P Digital Currency
Public Member Functions | Private Attributes | List of all members
http_bitcoin::HTTPHeaders Class Reference

#include <httpserver.h>

Public Member Functions

std::optional< std::string > FindFirst (std::string_view key) const
 
std::vector< std::string_view > FindAll (std::string_view key) const
 
void Write (std::string &&key, std::string &&value)
 
void RemoveAll (std::string_view key)
 
bool Read (util::LineReader &reader, bool write=true)
 
std::string Stringify () const
 

Private Attributes

std::vector< std::pair< std::string, std::string > > m_headers
 Headers can have duplicate field names, so we use a vector of key-value pairs instead of a map. More...
 
size_t m_consumed {0}
 Track total bytes consumed in Read() for limit checks. More...
 

Detailed Description

Definition at line 92 of file httpserver.h.

Member Function Documentation

◆ FindAll()

std::vector< std::string_view > http_bitcoin::HTTPHeaders::FindAll ( std::string_view  key) const
Parameters
[in]keyThe field-name of the header to search for
Returns
Views into all values matching the provided key (valid while this object is alive)

Definition at line 277 of file httpserver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindFirst()

std::optional< std::string > http_bitcoin::HTTPHeaders::FindFirst ( std::string_view  key) const
Parameters
[in]keyThe field-name of the header to search for
Returns
The value of the first header that matches the provided key nullopt if key is not found

Definition at line 267 of file httpserver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Read()

bool http_bitcoin::HTTPHeaders::Read ( util::LineReader reader,
bool  write = true 
)
Parameters
[in]readerA LineReader instance initialized with the client's receive buffer.
[in]writeWhether or not to write the parsed data to the object after validation.
Returns
false if LineReader hits the end of the buffer before reading an
, meaning that we are still waiting on more data from the client. true after reading an entire HTTP headers section, terminated by an empty line and
.
Exceptions
onexceeded read limit and on bad headers syntax (e.g. no ":" in a line)

Definition at line 301 of file httpserver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveAll()

void http_bitcoin::HTTPHeaders::RemoveAll ( std::string_view  key)
Parameters
[in]keyThe field-name of the header to search for and delete

Definition at line 293 of file httpserver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Stringify()

std::string http_bitcoin::HTTPHeaders::Stringify ( ) const

Definition at line 357 of file httpserver.cpp.

Here is the caller graph for this function:

◆ Write()

void http_bitcoin::HTTPHeaders::Write ( std::string &&  key,
std::string &&  value 
)

Definition at line 288 of file httpserver.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ m_consumed

size_t http_bitcoin::HTTPHeaders::m_consumed {0}
private

Track total bytes consumed in Read() for limit checks.

Definition at line 131 of file httpserver.h.

◆ m_headers

std::vector<std::pair<std::string, std::string> > http_bitcoin::HTTPHeaders::m_headers
private

Headers can have duplicate field names, so we use a vector of key-value pairs instead of a map.

https://httpwg.org/specs/rfc9110.html#rfc.section.5.2

Definition at line 128 of file httpserver.h.


The documentation for this class was generated from the following files: