mist/http

Types

pub opaque type Body
pub type Buffer {
  Buffer(remaining: Int, data: BitString)
}

Constructors

  • Buffer(remaining: Int, data: BitString)
pub type DecodeError {
  MalformedRequest
  InvalidMethod
  InvalidPath
  UnknownHeader
  UnknownMethod
  InvalidBody
  DiscardPacket
}

Constructors

  • MalformedRequest
  • InvalidMethod
  • InvalidPath
  • UnknownHeader
  • UnknownMethod
  • InvalidBody
  • DiscardPacket
pub type DecodedPacket {
  BinaryData(HttpPacket, BitString)
  EndOfHeaders(BitString)
  MoreData(Option(Int))
}

Constructors

  • BinaryData(HttpPacket, BitString)
  • EndOfHeaders(BitString)
  • MoreData(Option(Int))
pub type HttpPacket {
  HttpRequest(Dynamic, HttpUri, #(Int, Int))
  HttpHeader(Int, Atom, BitString, BitString)
}

Constructors

  • HttpRequest(Dynamic, HttpUri, #(Int, Int))
  • HttpHeader(Int, Atom, BitString, BitString)
pub type HttpResponseBody {
  BitBuilderBody(BitBuilder)
  Chunked(Iterator(BitBuilder))
  FileBody(
    file_descriptor: file.FileDescriptor,
    content_type: String,
    offset: Int,
    length: Int,
  )
}

Constructors

  • BitBuilderBody(BitBuilder)
  • Chunked(Iterator(BitBuilder))
  • FileBody(
      file_descriptor: file.FileDescriptor,
      content_type: String,
      offset: Int,
      length: Int,
    )
pub type HttpUri {
  AbsPath(BitString)
}

Constructors

  • AbsPath(BitString)
pub type PacketType {
  Http
  HttphBin
  HttpBin
}

Constructors

  • Http
  • HttphBin
  • HttpBin

Functions

pub fn add_default_headers(resp: Response(BitBuilder)) -> Response(
  BitBuilder,
)
pub fn from_header(value: BitString) -> String
pub fn parse_headers(bs: BitString, socket: Socket, transport: Transport, headers: Map(
    String,
    String,
  )) -> Result(#(Map(String, String), BitString), DecodeError)
pub fn parse_request(bs: BitString, socket: Socket, transport: Transport) -> Result(
  Request(Body),
  DecodeError,
)

Turns the TCP message into an HTTP request

pub fn read_body(req: Request(Body)) -> Result(
  Request(BitString),
  DecodeError,
)
pub fn read_data(socket: Socket, transport: Transport, buffer: Buffer, error: DecodeError) -> Result(
  BitString,
  DecodeError,
)
pub fn upgrade(socket: Socket, transport: Transport, req: Request(
    Body,
  )) -> Result(Nil, Nil)
pub fn upgrade_socket(req: Request(Body)) -> Result(
  Response(BitBuilder),
  Request(Body),
)
Search Document