pub struct Httpc { /* private fields */ }
Implementations
sourceimpl Httpc
impl Httpc
sourcepub fn new(con_offset: usize, cfg: Option<HttpcCfg>) -> Httpc
pub fn new(con_offset: usize, cfg: Option<HttpcCfg>) -> Httpc
Httpc will create connections with mio token in range [con_offset..con_offset+0xFFFF]
sourcepub fn open_connections(&self) -> usize
pub fn open_connections(&self) -> usize
Number of currently open connections (in active and idle keep-alive state)
sourcepub fn call_close(&mut self, id: Call)
pub fn call_close(&mut self, id: Call)
Prematurely finish call.
sourcepub fn timeout(&mut self) -> Vec<CallRef>
pub fn timeout(&mut self) -> Vec<CallRef>
Call periodically to check for call timeouts and DNS retries. Returns list of calls that have timed out. You must execute call_close yourself (or SimpleCall::abort) and timeout will return them every time until you do. (every 100ms for example)
sourcepub fn timeout_extend<C: TlsConnector>(&mut self, out: &mut Vec<CallRef>)
pub fn timeout_extend<C: TlsConnector>(&mut self, out: &mut Vec<CallRef>)
Same as timeout except that timed out calls get appended. This way you can reuse old allocations (if you truncated to 0).
sourcepub fn event(&mut self, ev: &Event) -> Option<CallRef>
pub fn event(&mut self, ev: &Event) -> Option<CallRef>
Get CallRef for ev if token in configured range for Httpc. Compare CallRef with external Call to find out which call this event belongs to if any.
This call is mandatory as it sets up internal data structures for when something is signalled! Even if you know which call is being signalled, you must call event to let mio_httpc know what state socket is in.
For streaming API first you must call call_send until you get a SendState::Receiving after that call is in receive state and you must call call_recv.
sourcepub fn call_send(
&mut self,
poll: &Poll,
id: &mut Call,
buf: Option<&[u8]>
) -> SendState
pub fn call_send(
&mut self,
poll: &Poll,
id: &mut Call,
buf: Option<&[u8]>
) -> SendState
If request has body it will be either taken from buf, from Request provided to CallBuilder or will return SendState::WaitReqBody.
buf slice is assumed to have taken previous SendState::SentBody(usize) into account and starts from part of buffer that has not been sent yet.
sourcepub fn call_recv(
&mut self,
poll: &Poll,
id: &mut Call,
buf: Option<&mut Vec<u8>>
) -> RecvState
pub fn call_recv(
&mut self,
poll: &Poll,
id: &mut Call,
buf: Option<&mut Vec<u8>>
) -> RecvState
If no buf provided, response body (if any) is stored in an internal buffer. If buf provided after some body has been received, it will be copied to it.
Buf will be expanded if required. Bytes are always appended. If you want to receive response entirely in buf, you should reserve capacity for entire body before calling call_recv.
If body is only stored in internal buffer it will be limited to CallBuilder::max_response.