On this page:
Response
Response.status_  line
Response.status_  code
Response.status_  message
Response.http_  version
Response.raw_  headers
Response.headers
Response.output
Response.body
Response.history
Response.close
Response.drain
Status  Code
current_  user_  agent
Response.handle
0.45+9.1

3 Responses🔗ℹ

class

class http.Response():

  expression ~none

  binding 'Response($field, ...)'

 

field

 = 

~status_line: bstr_bind

 | 

~status_code: status_code_bind

 | 

~status_message: bstr_bind

 | 

~http_version: bstr_bind

 | 

~history: response_list_bind

 | 

~headers: { key_str: bstr_bind, ... }

 | 

~headers: { key_str: bstr_bind, ..., & bstr_list_bind }

 | 

~body: bstr_bind

A Response represents a request sent via Session.request or through one of the shorthand functions like get.

A Response may still be in the process of receiving its data when it is returned, so methods like Response.body may block while data is read. A Response is Closeable via Response.close.

As a binding form, Response extracts and sometimes converts response information, blocking as needed until the information is available. The extracted information is matched against a given binding.

  • ~status_line: Matches the same byte string result as produced by Response.status_line.

  • ~status_code: Matches the same integer result as produced by Response.status_code.

  • ~status_message: Matches the same byte string result as produced by Response.status_message.

  • ~http_version: Matches the same byte string result as produced by Response.http_version.

  • ~history: Matches the list result as produced by Response.history.

  • ~headers: Matches against indivdual fields in a response header. These fields are located in the byte strings returned by Response.raw_headers, where key_strs are matched case-insensitively to field name, and each bstr_bind after a key_str is matched against the byte-string value of that field. If & bstr_list_bind is present, it is matched against the list of byte strings from Response.raw_headers, but with lines matched to key_strs removed.

  • ~body: Matches the byte string result as produced by Response.body.

property

property (resp :: http.Response).status_line :: Bytes

 

property

property (resp :: http.Response).status_code :: StatusCode

 

property

property (resp :: http.Response).status_message :: Bytes

 

property

property (resp :: http.Response).http_version :: Bytes

 

property

property (resp :: http.Response).raw_headers :: List.of(Bytes)

Accesses the raw immediate data for a request response.

method

method (resp :: http.Response).headers() :: Map.of(String, Bytes)

Returns the same result as Response.raw_headers, but parsed into a map from field names to values.

method

method (resp :: http.Response).output() :: Port.Input

 

method

method (resp :: http.Response).body() :: Bytes

The Response.output method returns an output port that provides the response’s body content. The Response.body method reads and records all data from that output port; calling Response.body a second time returns the same recorded data.

If Response.output is called after Response.body, then the returned output port will be closed. If ~stream: #false or ~close: #true were provided to Session.request to obtain the Response object, then Response.body is effectively called already.

method

method (resp :: http.Response).history() :: List.of(Response)

Reports redirections taken to arrive at the final response. The redirection responses are in reverse order in the result list (i.e., most recent first).

method

method (resp :: http.Response).close() :: Void

 

method

method (resp :: http.Response).drain() :: Void

The Response.close method terminates any communication still in process to reeceive the result.

The Response.drain method reads all data for the response body and records it. A Response.drain call has no effect if the content is already read.

annotation

http.StatusCode

Equivalent to Int.in(100 ..= 999) ~annot.

context parameter

Parameter.def http.current_user_agent :: String

Supplies a default value for the ~user_agent argument of Session.request, which determines the User-Agent field of the request.

property

property (resp :: http.Response).handle

Returns a Racket representation of the response.