Module jls.net.http.HttpExchange

Wraps the HTTP request and the associated response.

Class HttpExchange

httpExchange:getContext () Returns the HTTP context.
httpExchange:getSession () Returns the HTTP session.
httpExchange:getRequest () Returns the HTTP request.
httpExchange:getResponse () Returns the HTTP response.
httpExchange:getRequestMethod () Returns the HTTP request method.
httpExchange:getRequestHeaders () Returns the HTTP request headers.
httpExchange:getRequestArguments () Returns the captured values of the request target path using the context path.
httpExchange:getRequestPath () Returns the request path as replaced by the context.
httpExchange:getSearchParams () Returns the request query parameters as a table.
httpExchange:onClose () Returns a promise that resolves once the exchange is closed.
httpExchange:setResponseStatusCode (status[, reason[, body]]) Sets the status code for the response.
HttpExchange.ok (exchange[, body[, contentType]]) Updates the response with the OK status code, 200.
HttpExchange.badRequest (exchange[, reason]) Updates the response with the status code Bad Request, 400.
HttpExchange.forbidden (exchange[, reason]) Updates the response with the status code Forbidden, 403.
HttpExchange.notFound (exchange) Updates the response with the status code Not Found, 404.
HttpExchange.methodNotAllowed (exchange) Updates the response with the status code Method Not Allowed, 405.
HttpExchange.internalServerError (exchange[, reason]) Updates the response with the status code Internal Server Error, 500.


Class HttpExchange

The HttpExchange class wraps the HTTP request and response. This class inherits from HttpHeaders.
httpExchange:getContext ()
Returns the HTTP context. Only available during the request handling

Returns:

    HttpContext the HTTP context
httpExchange:getSession ()
Returns the HTTP session.

Returns:

    HttpSession the HTTP session
httpExchange:getRequest ()
Returns the HTTP request.

Returns:

    HttpMessage the HTTP request
httpExchange:getResponse ()
Returns the HTTP response.

Returns:

    HttpMessage the HTTP response
httpExchange:getRequestMethod ()
Returns the HTTP request method.

Returns:

    string the HTTP method
httpExchange:getRequestHeaders ()
Returns the HTTP request headers.

Returns:

    HttpHeaders the HTTP request
httpExchange:getRequestArguments ()
Returns the captured values of the request target path using the context path.

Returns:

    string the first captured value, nil if there is no captured value
httpExchange:getRequestPath ()
Returns the request path as replaced by the context.

Returns:

    string the request path
httpExchange:getSearchParams ()
Returns the request query parameters as a table.

Returns:

    table the query parameters
httpExchange:onClose ()
Returns a promise that resolves once the exchange is closed.

Returns:

    jls.lang.Promise a promise that resolves once the exchange is closed
httpExchange:setResponseStatusCode (status[, reason[, body]])
Sets the status code for the response.

Parameters:

  • status number the status code
  • reason string the reason phrase (optional)
  • body string the response body (optional)
HttpExchange.ok (exchange[, body[, contentType]])
Updates the response with the OK status code, 200.

Parameters:

  • exchange HttpExchange ongoing HTTP exchange
  • body string the response content (optional)
  • contentType string the response content type (optional)
HttpExchange.badRequest (exchange[, reason])
Updates the response with the status code Bad Request, 400.

Parameters:

  • exchange HttpExchange ongoing HTTP exchange
  • reason string the response reason phrase (optional)
HttpExchange.forbidden (exchange[, reason])
Updates the response with the status code Forbidden, 403.

Parameters:

  • exchange HttpExchange ongoing HTTP exchange
  • reason string the response reason phrase (optional)
HttpExchange.notFound (exchange)
Updates the response with the status code Not Found, 404.

Parameters:

HttpExchange.methodNotAllowed (exchange)
Updates the response with the status code Method Not Allowed, 405.

Parameters:

HttpExchange.internalServerError (exchange[, reason])
Updates the response with the status code Internal Server Error, 500.

Parameters:

  • exchange HttpExchange ongoing HTTP exchange
  • reason string the response reason phrase (optional)
generated by LDoc 1.4.6