kong.service.response

    Returns the HTTP status code of the response from the Service as a Lua number.

    Phases

    • , body_filter, log

    Returns

    Usage

    Returns a Lua table holding the headers from the Service response. Keys are header names. Values are either a string with the header value, or an array of strings if a header was sent multiple times. Header names in this table are case-insensitive and dashes (-) can be written as underscores (_); that is, the header X-Custom-Header can also be retrieved as x_custom_header.

    Unlike kong.response.get_headers(), this function only returns headers that are present in the response from the Service (ignoring headers added by Kong itself). If the request is not proxied to a Service (e.g. an authentication plugin rejected a request and produced an HTTP 401 response), then the returned headers value might be nil, since no response from the Service has been received.

    By default, this function returns up to 100 headers. The optional max_headers argument can be specified to customize this limit, but must be greater than 1 and not greater than 1000.

    Phases

    • , body_filter, log

    Parameters

    • max_headers (number, optional): Sets a limit on the maximum number of headers that can be parsed.
    1. table: The response headers in table form.

    2. string: If more headers than max_headers are present, returns a string with the error "truncated".

    Usage

    Returns the value of the specified response header.

    Unlike kong.response.get_header(), this function only returns a header if it is present in the response from the Service (ignoring headers added by Kong itself).

    Phases

    • header_filter, body_filter, log

    Parameters

    • name (string): The name of the header.

      Header names in are case-insensitive and are normalized to lowercase, and dashes (-) can be written as underscores (_); that is, the header can also be retrieved as x_custom_header.

    Usage

    Returns the raw buffered body.

    Phases

    • header_filter, body_filter, log

    Returns

    • string: The raw buffered body.

    Usage

    Returns the decoded buffered body.

    Phases

    • header_filter, body_filter, log

    Parameters

    • mimetype (string, optional): The MIME type of the response (if known).
    • max_args (number, optional): Sets a limit on the maximum number of (what?) that can be parsed.

    Returns

    • string: The raw buffered body