Response

class Response: HttpMessage
static source(source)

Create a request parser from a source function

Parameters:

source (function) – (pat:string|number|nil):string|nil,string|nil,string|nil

Return type:

Response or nil

Returns:

error if return 1 is nil the error string

Return type:

nil or str

static tcp_source(socket)

Create a response from a lua socket tcp socket

Parameters:

socket (table) – tcp socket

Return type:

Response or nil

Return type:

nil or str

static udp_source(socket)

Create a response from a lua socket udp socket

Parameters:

socket (table) – udp socket

Return type:

Response or nil

Return type:

nil or str

next_line()

Get the next line from an incoming request, checking first

if we have reached the end of the content

Return type:

str or nil

Return type:

str or nil

get_body()
static new(status_code, socket)

Create a new response for building in memory

Parameters:
  • status_code (number or nil) – if not provided 200

  • socket (table or nil) – luasocket for sending (not required)

set_status(n)

Set the status for this outgoing request

Parameters:

n (number or str) – the 3 digit status

Returns:

response

Return type:

Response or nil

Returns:

error

Return type:

nil or str

has_sent()