Struct Http1Builder
struct Http1Builder<'a, E> { ... }
Http1 part of builder.
Implementations
impl<E> Http1Builder<'_, E>
fn http2(self: &mut Self) -> Http2Builder<'_, E>Http2 configuration.
fn auto_date_header(self: &mut Self, enabled: bool) -> &mut SelfSet whether the
dateheader should be included in HTTP responses.Note that including the
dateheader is recommended by RFC 7231.Default is true.
fn half_close(self: &mut Self, val: bool) -> &mut SelfSet whether HTTP/1 connections should support half-closures.
Clients can chose to shutdown their write-side while waiting for the server to respond. Setting this to
truewill prevent closing the connection immediately ifreaddetects an EOF in the middle of a request.Default is
false.fn keep_alive(self: &mut Self, val: bool) -> &mut SelfEnables or disables HTTP/1 keep-alive.
Default is true.
fn title_case_headers(self: &mut Self, enabled: bool) -> &mut SelfSet whether HTTP/1 connections will write header names as title case at the socket level.
Note that this setting does not affect HTTP/2.
Default is false.
fn ignore_invalid_headers(self: &mut Self, enabled: bool) -> &mut SelfSet whether HTTP/1 connections will silently ignored malformed header lines.
If this is enabled and a header line does not start with a valid header name, or does not include a colon at all, the line will be silently ignored and no error will be reported.
Default is false.
fn preserve_header_case(self: &mut Self, enabled: bool) -> &mut SelfSet whether to support preserving original header cases.
Currently, this will record the original cases received, and store them in a private extension on the
Request. It will also look for and use such an extension in any providedResponse.Since the relevant extension is still private, there is no way to interact with the original cases. The only effect this can have now is to forward the cases in a proxy-like fashion.
Note that this setting does not affect HTTP/2.
Default is false.
fn max_headers(self: &mut Self, val: usize) -> &mut SelfSet the maximum number of headers.
When a request is received, the parser will reserve a buffer to store headers for optimal performance.
If server receives more headers than the buffer size, it responds to the client with "431 Request Header Fields Too Large".
The headers is allocated on the stack by default, which has higher performance. After setting this value, headers will be allocated in heap memory, that is, heap memory allocation will occur for each request, and there will be a performance drop of about 5%.
Note that this setting does not affect HTTP/2.
Default is 100.
fn header_read_timeout<impl Into<Option<Duration>>: Into<Option<Duration>>>(self: &mut Self, read_timeout: impl Into<Option<Duration>>) -> &mut SelfSet a timeout for reading client request headers. If a client does not transmit the entire header within this time, the connection is closed.
Requires a
Timerset byHttp1Builder::timerto take effect. Panics ifheader_read_timeoutis configured without aTimer.Pass
Noneto disable.Default is currently 30 seconds, but do not depend on that.
fn writev(self: &mut Self, val: bool) -> &mut SelfSet whether HTTP/1 connections should try to use vectored writes, or always flatten into a single buffer.
Note that setting this to false may mean more copies of body data, but may also improve performance when an IO transport doesn't support vectored writes well, such as most TLS implementations.
Setting this to true will force hyper to use queued strategy which may eliminate unnecessary cloning on some TLS backends
Default is
auto. In this mode hyper will try to guess which mode to usefn max_buf_size(self: &mut Self, max: usize) -> &mut SelfSet the maximum buffer size for the connection.
Default is ~400kb.
Panics
The minimum value allowed is 8192. This method panics if the passed
maxis less than the minimum.fn pipeline_flush(self: &mut Self, enabled: bool) -> &mut SelfAggregates flushes to better support pipelined responses.
Experimental, may have bugs.
Default is false.
fn timer<M>(self: &mut Self, timer: M) -> &mut Self where M: Timer + Send + Sync + 'staticSet the timer used in background tasks.
async fn serve_connection<I, S, B>(self: &Self, io: I, service: S) -> Result<(), Box<dyn Error + Send + Sync>> where S: Service<Request<Incoming>, Response = Response<B>>, <S as >::Future: 'static, <S as >::Error: Into<Box<dyn StdError + Send + Sync>>, B: Body + 'static, <B as >::Error: Into<Box<dyn StdError + Send + Sync>>, I: Read + Write + Unpin + 'static, E: HttpServerConnExec<<S as >::Future, B>Bind a connection together with a
Service.fn serve_connection_with_upgrades<I, S, B>(self: &Self, io: I, service: S) -> UpgradeableConnection<'_, I, S, E> where S: Service<Request<Incoming>, Response = Response<B>>, <S as >::Future: 'static, <S as >::Error: Into<Box<dyn StdError + Send + Sync>>, B: Body + 'static, <B as >::Error: Into<Box<dyn StdError + Send + Sync>>, I: Read + Write + Unpin + Send + 'static, E: HttpServerConnExec<<S as >::Future, B>Bind a connection together with a
Service, with the ability to handle HTTP upgrades. This requires that the IO object implementsSend.
impl<'a, E> Freeze for Http1Builder<'a, E>
impl<'a, E> RefUnwindSafe for Http1Builder<'a, E>
impl<'a, E> Send for Http1Builder<'a, E>
impl<'a, E> Sync for Http1Builder<'a, E>
impl<'a, E> Unpin for Http1Builder<'a, E>
impl<'a, E> UnsafeUnpin for Http1Builder<'a, E>
impl<'a, E> UnwindSafe for Http1Builder<'a, E>
impl<T> Any for Http1Builder<'a, E>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Http1Builder<'a, E>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Http1Builder<'a, E>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for Http1Builder<'a, E>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Instrument for Http1Builder<'a, E>
impl<T> WithSubscriber for Http1Builder<'a, E>
impl<T, U> Into for Http1Builder<'a, E>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Http1Builder<'a, E>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Http1Builder<'a, E>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>