Struct bitcoin_http::HTTPRequest
source · pub struct HTTPRequest { /* private fields */ }
Expand description
| In-flight HTTP request. | | Thin C++ wrapper around evhttp_request. |
Implementations§
source§impl HTTPRequest
impl HTTPRequest
pub fn new(req: *mut evhttp_request, reply_sent: Option<bool>) -> Self
sourcepub fn get_header(&self, hdr: &String) -> (bool, String)
pub fn get_header(&self, hdr: &String) -> (bool, String)
| Get the request header specified by | hdr, or an empty string. | | Return a pair (isPresent,string). |
sourcepub fn read_body(&mut self) -> String
pub fn read_body(&mut self) -> String
| Read request body. | | ———– | @note | | As this consumes the underlying buffer, | call this only once. | | Repeated calls will return an empty | string. |
sourcepub fn write_header(&mut self, hdr: &String, value: &String)
pub fn write_header(&mut self, hdr: &String, value: &String)
| Write output header. | | ———– | @note | | call this before calling WriteErrorReply | or Reply. |
sourcepub fn write_reply(&mut self, n_status: i32, str_reply: Option<&str>)
pub fn write_reply(&mut self, n_status: i32, str_reply: Option<&str>)
| Closure sent to main thread to request | a reply to be sent to a HTTP request. | | Replies must be sent in the main loop | in the main http thread, this cannot | be done from worker threads. |
| Write HTTP reply. nStatus is the HTTP | status code to send. strReply is the | body of the reply. Keep it empty to send | a standard message. | | ———– | @note | | Can be called only once. As this will | give the request back to the main thread, | do not call any other HTTPRequest methods | after calling this. |
sourcepub fn get_peer(&self) -> Service
pub fn get_peer(&self) -> Service
| Get CService (address:ip) for the origin | of the http request. |
sourcepub fn get_request_method(&self) -> RequestMethod
pub fn get_request_method(&self) -> RequestMethod
| Get request method. |