![]() |
Bitcoin Core 32.1.0
P2P Digital Currency
|
#include <httpserver.h>
Public Types | |
| enum class | State { Init , NeedsHeaders , NeedsBody , Complete , Error } |
Public Member Functions | |
| HTTPRequest (const std::shared_ptr< HTTPRemoteClient > &client) | |
| HTTPRequest () | |
| Construct with a null client for unit tests. | |
| void | WriteReply (HTTPStatusCode status, std::span< const std::byte > reply_body={}) |
| void | WriteReply (HTTPStatusCode status, std::string_view reply_body_view) |
| const HTTPVersion & | GetVersion () const |
| std::shared_ptr< HTTPRemoteClient > | GetClient () const |
| std::string | GetURI () const |
| CService | GetPeer () const |
| HTTPRequestMethod | GetRequestMethod () const |
| std::optional< std::string > | GetQueryParameter (std::string_view key) const |
| std::optional< std::string > | GetHeader (std::string_view hdr) const |
| std::string | ReadBody () const |
| void | WriteHeader (std::string &&hdr, std::string &&value) |
| std::optional< uint64_t > | GetChunkSize () const |
| uint64_t | GetChunkProgress () const |
| State | GetState () const |
| void | SetState (State state) |
| bool | LoadControlData (util::LineReader &reader) |
| Methods that attempt to parse HTTP request fields line-by-line from a receive buffer. | |
| bool | LoadHeaders (util::LineReader &reader) |
| bool | LoadBody (util::LineReader &reader) |
Private Attributes | |
| HTTPRequestMethod | m_method |
| std::string | m_target |
| HTTPVersion | m_version |
| HTTPHeaders | m_headers |
| std::string | m_body |
| std::weak_ptr< HTTPRemoteClient > | m_client |
| Pointer to the client that made the request so we know who to respond to. | |
| HTTPHeaders | m_response_headers |
| Response headers may be set in advance before response body is known. | |
| std::optional< uint64_t > | m_chunk_size |
| uint64_t | m_chunk_read {0} |
| State | m_state = State::Init |
Definition at line 154 of file httpserver.h.
|
strong |
| Enumerator | |
|---|---|
| Init | |
| NeedsHeaders | |
| NeedsBody | |
| Complete | |
| Error | |
Definition at line 196 of file httpserver.h.
|
inlineexplicit |
Definition at line 157 of file httpserver.h.
|
inlineexplicit |
Construct with a null client for unit tests.
Definition at line 159 of file httpserver.h.
|
inline |
Definition at line 194 of file httpserver.h.
|
inline |
Definition at line 193 of file httpserver.h.
|
inline |
Definition at line 182 of file httpserver.h.
| std::optional< std::string > HTTPRequest::GetHeader | ( | std::string_view | hdr | ) | const |
Definition at line 698 of file httpserver.cpp.
| CService HTTPRequest::GetPeer | ( | ) | const |
| std::optional< std::string > HTTPRequest::GetQueryParameter | ( | std::string_view | key | ) | const |
Definition at line 666 of file httpserver.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
| bool HTTPRequest::LoadBody | ( | util::LineReader & | reader | ) |
Definition at line 431 of file httpserver.cpp.
| bool HTTPRequest::LoadControlData | ( | util::LineReader & | reader | ) |
Methods that attempt to parse HTTP request fields line-by-line from a receive buffer.
| [in] | reader | A LineReader object constructed over a span of data. |
| std::runtime_error | if data is invalid. |
Definition at line 378 of file httpserver.cpp.
| bool HTTPRequest::LoadHeaders | ( | util::LineReader & | reader | ) |
Definition at line 426 of file httpserver.cpp.
|
inline |
|
inline |
| void HTTPRequest::WriteHeader | ( | std::string && | hdr, |
| std::string && | value ) |
Definition at line 703 of file httpserver.cpp.
| void HTTPRequest::WriteReply | ( | HTTPStatusCode | status, |
| std::span< const std::byte > | reply_body = {} ) |
Definition at line 535 of file httpserver.cpp.
|
inline |
|
private |
Definition at line 211 of file httpserver.h.
|
private |
Definition at line 225 of file httpserver.h.
|
private |
Definition at line 222 of file httpserver.h.
|
private |
Pointer to the client that made the request so we know who to respond to.
Definition at line 214 of file httpserver.h.
|
private |
Definition at line 210 of file httpserver.h.
|
private |
Definition at line 207 of file httpserver.h.
|
private |
Response headers may be set in advance before response body is known.
Definition at line 217 of file httpserver.h.
|
private |
Definition at line 227 of file httpserver.h.
|
private |
Definition at line 208 of file httpserver.h.
|
private |
Definition at line 209 of file httpserver.h.