![]() |
Bitcoin Core 32.99.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. | |
| State | Load (util::LineReader &reader) |
| Try to read an HTTP request or part of it. | |
| 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 LIFETIMEBOUND |
| 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 |
Private Member Functions | |||
Request parsers | |||
Methods that attempt to parse HTTP request fields line-by-line from a receive buffer.
| |||
| bool | LoadControlData (util::LineReader &reader) | ||
| 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 155 of file httpserver.h.
|
strong |
| Enumerator | |
|---|---|
| Init | |
| NeedsHeaders | |
| NeedsBody | |
| Complete | |
| Error | |
Definition at line 158 of file httpserver.h.
|
inlineexplicit |
Definition at line 166 of file httpserver.h.
|
inlineexplicit |
Construct with a null client for unit tests.
Definition at line 168 of file httpserver.h.
|
inline |
Definition at line 197 of file httpserver.h.
|
inline |
Definition at line 196 of file httpserver.h.
|
inline |
Definition at line 185 of file httpserver.h.
| std::optional< std::string > HTTPRequest::GetHeader | ( | std::string_view | hdr | ) | const |
Definition at line 697 of file httpserver.cpp.
| CService HTTPRequest::GetPeer | ( | ) | const |
Definition at line 656 of file httpserver.cpp.
| std::optional< std::string > HTTPRequest::GetQueryParameter | ( | std::string_view | key | ) | const |
Definition at line 665 of file httpserver.cpp.
|
inline |
|
inline |
Definition at line 199 of file httpserver.h.
|
inline |
|
inline |
| HTTPRequest::State HTTPRequest::Load | ( | util::LineReader & | reader | ) |
Try to read an HTTP request or part of it.
| [in] | reader | Source of client request data. |
| std::runtime_error | if data is invalid. |
Definition at line 1230 of file httpserver.cpp.
|
private |
Definition at line 430 of file httpserver.cpp.
|
private |
Definition at line 377 of file httpserver.cpp.
|
private |
Definition at line 425 of file httpserver.cpp.
|
inline |
| void HTTPRequest::WriteHeader | ( | std::string && | hdr, |
| std::string && | value | ||
| ) |
Definition at line 702 of file httpserver.cpp.
| void HTTPRequest::WriteReply | ( | HTTPStatusCode | status, |
| std::span< const std::byte > | reply_body = {} |
||
| ) |
Definition at line 534 of file httpserver.cpp.
|
inline |
|
private |
Definition at line 220 of file httpserver.h.
|
private |
Definition at line 234 of file httpserver.h.
|
private |
Definition at line 231 of file httpserver.h.
|
private |
Pointer to the client that made the request so we know who to respond to.
Definition at line 223 of file httpserver.h.
|
private |
Definition at line 219 of file httpserver.h.
|
private |
Definition at line 216 of file httpserver.h.
|
private |
Response headers may be set in advance before response body is known.
Definition at line 226 of file httpserver.h.
|
private |
Definition at line 236 of file httpserver.h.
|
private |
Definition at line 217 of file httpserver.h.
|
private |
Definition at line 218 of file httpserver.h.