Struct http::Response

Overview

A Response to a submitted [Request].

Methods

async fn text(self) -> Result

Get the response as text.

let client = http::Client::new();

let response = client.get("http://example.com")
   .body_bytes(b"Hello World")
   .send()
   .await?;

let response = response.text().await?;
async fn json(self) -> Result

Get the response as a Rune value decoded from JSON.

let client = http::Client::new();

let response = client.get("http://example.com")
   .send()
   .await?;

let response = response.json().await?;
async fn bytes(self) -> Result

Get the response as bytes.

let client = http::Client::new();

let response = client.get("http://example.com")
   .send()
   .await?;

let response = response.bytes().await?;

Get the status code of the response.

Get the version of the response.

Get the content-length of this response, if known.

Reasons it may not be known:

  • The server didn't send a content-length header.
  • The response is compressed and automatically decoded (thus changing the actual decoded length).