flix

0.70.0

Net.HttpResponse

enum HttpResponseSource
case HttpResponse({ body = Body, headers = Map[String, List[String]], status = Int32, url = String })

An HTTP response with final URL, status code, multi-valued headers, and body.

Definitions

def body(r: HttpResponse): String Source

Returns the body of the response r as a string.

If the body is binary, it is decoded as UTF-8.

def bodyBytes(r: HttpResponse): Vector[Int8] Source

Returns the body of the response r as bytes.

If the body is text, it is encoded as UTF-8.

def contentLength(r: HttpResponse): Option[Int64] Source

Returns the value of the content-length header parsed as an Int64, or None if not present or not a valid number.

def contentType(r: HttpResponse): Option[String] Source

Returns the value of the content-type header, or None if not present.

def expect(r: HttpResponse): Result[IoError, HttpResponse] Source

Returns Ok(r) if the response status is in the 2xx range, or Err otherwise.

def header(name: String, r: HttpResponse): Option[List[String]] Source

Returns the list of values for the header with the given name, or None if not present.

def headerValue(name: String, r: HttpResponse): Option[String] Source

Returns the first value of the header with the given name, or None if not present.

def headers(r: HttpResponse): Map[String, List[String]] Source

Returns the headers of the response r.

def isClientError(r: HttpResponse): Bool Source

Returns true if the response status is in the 4xx range.

def isError(r: HttpResponse): Bool Source

Returns true if the response status is in the 4xx or 5xx range.

def isOk(r: HttpResponse): Bool Source

Returns true if the response status is 200 OK.

def isRedirect(r: HttpResponse): Bool Source

Returns true if the response status is in the 3xx range.

def isServerError(r: HttpResponse): Bool Source

Returns true if the response status is in the 5xx range.

def isSuccess(r: HttpResponse): Bool Source

Returns true if the response status is in the 2xx range.

def status(r: HttpResponse): Int32 Source

Returns the status code of the response r.

def url(r: HttpResponse): String Source

Returns the final URL of the response r (after any redirects).