#[non_exhaustive]pub enum ClientEvent<'a> {
Response(ResponseHead<'a>),
Informational(ResponseHead<'a>),
Continue,
Body(&'a [u8]),
Trailers(Headers<'a>),
ResponseEnd,
NeedInput,
Idle,
Upgraded,
Closed,
}Expand description
What a ClientConn has for the caller after poll.
§Examples
use http_net::{ClientConn, ClientEvent, Request};
let mut conn = ClientConn::new();
let mut out = Vec::new();
conn.send_request(&Request::get("/").header("host", "example.com"), &mut out).unwrap();
let _ = conn.feed(b"HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n3\r\nabc\r\n0\r\n\r\n");
let mut body = Vec::new();
loop {
match conn.poll().unwrap() {
ClientEvent::Response(resp) => assert_eq!(resp.status(), 200),
ClientEvent::Body(chunk) => body.extend_from_slice(chunk),
ClientEvent::ResponseEnd => break,
other => panic!("{other:?}"),
}
}
assert_eq!(body, b"abc");Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Response(ResponseHead<'a>)
The final response head arrived. Its body follows as
Body events, then
ResponseEnd. Interim (1xx) responses
before it are skipped unless
set_report_informational
asked for them; either way they count against
Limits::max_interim and, together,
Limits::max_header_bytes.
Informational(ResponseHead<'a>)
An interim response other than 101 (for example 103 Early Hints,
or 102 Processing), only with
set_report_informational(true).
The final response follows.
Continue
The server answered 100 Continue to a request built with
Request::expect_continue: send
the body now.
Body(&'a [u8])
A run of body bytes, after chunked decoding.
Trailers(Headers<'a>)
The response’s trailer fields, just before
ResponseEnd: only with
set_report_trailers(true) and a
non-empty trailer section.
ResponseEnd
The response is complete.
NeedInput
More input is needed (or, for a body that runs until close,
feed_eof once the server closes).
Idle
No request is outstanding; send the next one.
Upgraded
The server switched protocols (101 to an upgrade request, or 2xx to
CONNECT); the response head was reported just before. Bytes of the
new protocol that already arrived are in
remaining_input.
Closed
The connection cannot carry another request: close the socket.