Module buffet.resty

OpenResty flavor of buffet objects.

Functions

new([data]) Create a new buffet object.

Class buffet

buffet:receive([size_or_pattern]) Read the data according to the reading pattern or size.
buffet:receiveany(max) Read the data, at most max bytes.
buffet:receiveuntil(pattern[, options]) Get an iterator to read the data until the specified pattern.
buffet:send(data) Send data.
buffet:close() Close the buffet.
buffet:connect(...) Connect the buffet.
buffet:sslhandshake(...) Do SSL/TLS handshake.
buffet:settimeout(...) Set the timeout value.
buffet:settimeouts(...) Set the connect, send, and read timeout values.
buffet:setoption(...) Set a socket option.
buffet:setkeepalive(...) Put the connection into the cosocket connection pool.
buffet:getreusedtimes() Get reused times for the connection.


Functions

new([data])
Create a new buffet object.

Parameters:

  • data string, table or function input data, one of:

    • a byte string
    • an array-like table of byte strings (be aware that the object will use the same table, not a copy)
    • an iterator function producing byte strings

    If the parameter is omitted or nil, this is roughly equivalent to passing an empty string. (optional)

Returns:

    buffet a buffet object

Or

  1. nil
  2. string an error

Class buffet

OpenResty buffet type
buffet:receive([size_or_pattern])
Read the data according to the reading pattern or size.

See Lua Nginx Module documentation.

Parameters:

  • size_or_pattern number or string a size of data to read or a pattern:

    • '*a' to read all data
    • '*l' to read a line

    If no parameter is specified, then it is assumed to be the pattern '*l'. (optional)

Returns:

    string data

Or

  1. nil
  2. string an error
  3. string partial data

Or

  1. nil
  2. string an error
buffet:receiveany(max)
Read the data, at most max bytes.

The main difference between receive(size) and receiveany(max) is that the latter doesn't read the next chunk from the input table/iterator if there is any data in the internal buffer left over from the previous calls.

See Lua Nginx Module documentation.

Parameters:

  • max number or string a max size of data to read

Returns:

    string data

Or

  1. nil
  2. string an error
  3. string an empty string (this is an undocumented quirk of the Lua Nginx Module)

Or

  1. nil
  2. string an error
buffet:receiveuntil(pattern[, options])
Get an iterator to read the data until the specified pattern.

See Lua Nginx Module documentation.

Parameters:

  • pattern string
  • options table (optional)

Returns:

    function an iterator

Or

  1. nil
  2. string an error
buffet:send(data)
Send data.

Appends a string representation of the data to the internal send buffer. Use buffet.get_send_buffer to access the buffer or buffet.get_sent_data to get the content of the buffer as a string.

The data parameter can be:

  • a string
  • an array-like table containing strings (possibly nested)
  • a number, boolean or nil (will be converted to a string)

See Lua Nginx Module documentation.

Parameters:

  • data string, table, number, boolean or nil the data to send

Returns:

    number number of bytes have been sent

Or

  1. nil
  2. string an error
buffet:close()
Close the buffet.

Marks the object as closed. Removes the reference to the input data.

See Lua Nginx Module documentation.

Returns:

    number 1 in case of success

Or

  1. nil
  2. string an error
buffet:connect(...)
Connect the buffet.

This method is almost noop, it only marks the object as “connected” (not closed). The return status is always success (1).

See Lua Nginx Module documentation.

Parameters:

  • ... any not checked, not used

Returns:

    number 1
buffet:sslhandshake(...)
Do SSL/TLS handshake.

This method is noop. If the buffet is not closed, the method returns true (as if false was passed as the reused_session argument). Otherwise, the method returns nil and an error.

See Lua Nginx Module documentation.

Parameters:

  • ... any not checked, not used

Returns:

    boolean true

Or

  1. nil
  2. string an error
buffet:settimeout(...)
Set the timeout value.

This method is noop. The method returns nothing.

See Lua Nginx Module documentation.

Parameters:

  • ... any not checked, not used
buffet:settimeouts(...)
Set the connect, send, and read timeout values.

This method is noop. The method returns nothing.

See Lua Nginx Module documentation.

Parameters:

  • ... any not checked, not used
buffet:setoption(...)
Set a socket option.

This method is noop. The method returns nothing.

See Lua Nginx Module documentation.

Parameters:

  • ... any not checked, not used
buffet:setkeepalive(...)
Put the connection into the cosocket connection pool.

This method is equivalent to the close method.

See Lua Nginx Module documentation.

Parameters:

  • ... any not checked, not used

Returns:

    number 1 in case of success

Or

  1. nil
  2. string an error
buffet:getreusedtimes()
Get reused times for the connection.

This method is noop. The return value is always 0.

See Lua Nginx Module documentation.

Returns:

    number 0

Or

  1. nil
  2. string an error
generated by LDoc 1.4.6 Last updated 2020-07-05 03:23:30