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

#include <httpserver.h>

Collaboration diagram for http_bitcoin::HTTPRequest:
[legend]

Public Member Functions

 HTTPRequest (std::shared_ptr< HTTPRemoteClient > client)
 
 HTTPRequest ()
 Construct with a null client for unit tests. More...
 
void WriteReply (HTTPStatusCode status, std::span< const std::byte > reply_body={})
 
void WriteReply (HTTPStatusCode status, std::string_view reply_body_view)
 
std::string GetURI () const
 
CService GetPeer () const
 
HTTPRequestMethod GetRequestMethod () const
 
std::optional< std::string > GetQueryParameter (std::string_view key) const
 
std::pair< bool, std::string > GetHeader (std::string_view hdr) const
 
std::string ReadBody () const
 
void WriteHeader (std::string &&hdr, std::string &&value)
 
bool LoadControlData (LineReader &reader)
 Methods that attempt to parse HTTP request fields line-by-line from a receive buffer. More...
 
bool LoadHeaders (LineReader &reader)
 
bool LoadBody (LineReader &reader)
 

Public Attributes

HTTPRequestMethod m_method
 
std::string m_target
 
HTTPVersion m_version
 
HTTPHeaders m_headers
 
std::string m_body
 
std::shared_ptr< HTTPRemoteClientm_client
 Pointer to the client that made the request so we know who to respond to. More...
 
HTTPHeaders m_response_headers
 Response headers may be set in advance before response body is known. More...
 

Detailed Description

Definition at line 150 of file httpserver.h.

Constructor & Destructor Documentation

◆ HTTPRequest() [1/2]

http_bitcoin::HTTPRequest::HTTPRequest ( std::shared_ptr< HTTPRemoteClient client)
inlineexplicit

Definition at line 165 of file httpserver.h.

◆ HTTPRequest() [2/2]

http_bitcoin::HTTPRequest::HTTPRequest ( )
inlineexplicit

Construct with a null client for unit tests.

Definition at line 167 of file httpserver.h.

Member Function Documentation

◆ GetHeader()

std::pair< bool, std::string > http_bitcoin::HTTPRequest::GetHeader ( std::string_view  hdr) const

Definition at line 661 of file httpserver.cpp.

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

◆ GetPeer()

CService http_bitcoin::HTTPRequest::GetPeer ( ) const

Definition at line 624 of file httpserver.cpp.

Here is the caller graph for this function:

◆ GetQueryParameter()

std::optional< std::string > http_bitcoin::HTTPRequest::GetQueryParameter ( std::string_view  key) const

Definition at line 629 of file httpserver.cpp.

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

◆ GetRequestMethod()

HTTPRequestMethod http_bitcoin::HTTPRequest::GetRequestMethod ( ) const
inline

Definition at line 193 of file httpserver.h.

Here is the caller graph for this function:

◆ GetURI()

std::string http_bitcoin::HTTPRequest::GetURI ( ) const
inline

Definition at line 191 of file httpserver.h.

Here is the caller graph for this function:

◆ LoadBody()

bool http_bitcoin::HTTPRequest::LoadBody ( LineReader reader)

Definition at line 420 of file httpserver.cpp.

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

◆ LoadControlData()

bool http_bitcoin::HTTPRequest::LoadControlData ( LineReader reader)

Methods that attempt to parse HTTP request fields line-by-line from a receive buffer.

Parameters
[in]readerA LineReader object constructed over a span of data.
Returns
true If the request field was parsed. false If there was not enough data in the buffer to complete the field.
Exceptions
std::runtime_errorif data is invalid.

Definition at line 367 of file httpserver.cpp.

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

◆ LoadHeaders()

bool http_bitcoin::HTTPRequest::LoadHeaders ( LineReader reader)

Definition at line 415 of file httpserver.cpp.

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

◆ ReadBody()

std::string http_bitcoin::HTTPRequest::ReadBody ( ) const
inline

Definition at line 196 of file httpserver.h.

Here is the caller graph for this function:

◆ WriteHeader()

void http_bitcoin::HTTPRequest::WriteHeader ( std::string &&  hdr,
std::string &&  value 
)

Definition at line 667 of file httpserver.cpp.

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

◆ WriteReply() [1/2]

void http_bitcoin::HTTPRequest::WriteReply ( HTTPStatusCode  status,
std::span< const std::byte >  reply_body = {} 
)

Definition at line 515 of file httpserver.cpp.

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

◆ WriteReply() [2/2]

void http_bitcoin::HTTPRequest::WriteReply ( HTTPStatusCode  status,
std::string_view  reply_body_view 
)
inline

Definition at line 184 of file httpserver.h.

Here is the call graph for this function:

Member Data Documentation

◆ m_body

std::string http_bitcoin::HTTPRequest::m_body

Definition at line 157 of file httpserver.h.

◆ m_client

std::shared_ptr<HTTPRemoteClient> http_bitcoin::HTTPRequest::m_client

Pointer to the client that made the request so we know who to respond to.

Definition at line 160 of file httpserver.h.

◆ m_headers

HTTPHeaders http_bitcoin::HTTPRequest::m_headers

Definition at line 156 of file httpserver.h.

◆ m_method

HTTPRequestMethod http_bitcoin::HTTPRequest::m_method

Definition at line 153 of file httpserver.h.

◆ m_response_headers

HTTPHeaders http_bitcoin::HTTPRequest::m_response_headers

Response headers may be set in advance before response body is known.

Definition at line 163 of file httpserver.h.

◆ m_target

std::string http_bitcoin::HTTPRequest::m_target

Definition at line 154 of file httpserver.h.

◆ m_version

HTTPVersion http_bitcoin::HTTPRequest::m_version

Definition at line 155 of file httpserver.h.


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