Skip to content

BuildableResponse

[Source]

Build your own HTTP Responses (minus the body) and turn them into immutable things to send around.

This class can be serialized in the following ways:

  • to Array[U8]: BuildableResponse.array()
  • to ByteArrays: BuildableResponse.to_bytes()

or by using it as a ByteSeqIter.

This class exists if you want to use the verbose API of Session and brings lots of convenience, like getters and setters for all common properties.

If you are looking for a more efficient way to build responses, use a ResponseBuilder as it is returned from Responses.builder(), this class is not introspectable and only allows adding properties the way they are put on the serialized form in the request. E.g. you must first set the status and then the headers, not the other way around. But it makes for a more efficient API.

class val BuildableResponse is
  Response val,
  ByteSeqIter val

Implements


Constructors

create

[Source]

new trn create(
  status': Status val = reference,
  version': ((HTTP09 val | HTTP10 val | HTTP11 val) & _Version val) = reference)
: BuildableResponse trn^

Parameters

Returns


Public Functions

version

[Source]

fun box version()
: ((HTTP09 val | HTTP10 val | HTTP11 val) & _Version val)

Returns


set_version

[Source]

fun ref set_version(
  v: ((HTTP09 val | HTTP10 val | HTTP11 val) & _Version val))
: BuildableResponse ref

Parameters

Returns


status

[Source]

fun box status()
: Status val

Returns


set_status

[Source]

fun ref set_status(
  s: Status val)
: BuildableResponse ref

Parameters

Returns


[Source]

fun box header(
  name: String val)
: (String val | None val)

Parameters

Returns


headers

[Source]

fun box headers()
: Iterator[(String val , String val)] ref

Returns


add_header

[Source]

fun ref add_header(
  name: String val,
  value: String val)
: BuildableResponse ref

Parameters

Returns


set_header

[Source]

fun ref set_header(
  name: String val,
  value: String val)
: BuildableResponse ref

Parameters

Returns


delete_header

[Source]

fun ref delete_header(
  name: String val)
: BuildableResponse ref

Parameters

Returns


clear_headers

[Source]

fun ref clear_headers()
: BuildableResponse ref

Returns


transfer_encoding

[Source]

fun box transfer_encoding()
: (Chunked val | None val)

Returns


set_transfer_encoding

[Source]

fun ref set_transfer_encoding(
  c: (Chunked val | None val))
: BuildableResponse ref

Parameters

Returns


content_length

[Source]

fun box content_length()
: (USize val | None val)

Returns


set_content_length

[Source]

Set or un-set the Content-Length header.

fun ref set_content_length(
  cl: (USize val | None val))
: BuildableResponse ref

Parameters

Returns


array

[Source]

fun box array()
: Array[U8 val] iso^

Returns


to_bytes

[Source]

fun box to_bytes()
: ByteArrays val

Returns


values

[Source]

Make this a very inefficient ByteSeqIter. Rather use array() if you care about performance.

fun box values()
: Iterator[(this->String box | this->Array[U8 val] box)] ref

Returns