[][src]Function surf::connect

pub fn connect(uri: impl AsRef<str>) -> RequestBuilder

Notable traits for RequestBuilder

impl Future for RequestBuilder type Output = Result<Response>;

Perform a one-off CONNECT request.

About the HTTP Method

The HTTP CONNECT method method starts two-way communications with the requested resource. It can be used to open a tunnel.

For example, the CONNECT method can be used to access websites that use SSL (HTTPS). The client asks an HTTP Proxy server to tunnel the TCP connection to the desired destination. The server then proceeds to make the connection on behalf of the client. Once the connection has been established by the server, the Proxy server continues to proxy the TCP stream to and from the client.

CONNECT is a hop-by-hop method.

Read more on MDN

Panics

This will panic if a malformed URL is passed.

Errors

Returns errors from the middleware, http backend, and network sockets.

Examples

let string = surf::connect("https://httpbin.org/connect").recv_string().await?;