Module jls.net.http.HttpExchange

The HttpExchange class wraps the HTTP request and response.

Class HttpExchange

httpExchange:getContext () Returns the HTTP context.
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:onRequestBody ([buffer]) Returns a promise that resolves once the request body is available.
httpExchange:onClose () Returns a promise that resolves once the exchange is closed.
httpExchange:setResponseStatusCode (statusCode[, reasonPhrase[, body]]) Sets the status code for the response.
HttpExchange.ok (httpExchange[, body[, contentType]]) Updates the response with the OK status code, 200.
HttpExchange.badRequest (httpExchange[, reasonPhrase]) Updates the response with the status code Bad Request, 400.
HttpExchange.forbidden (httpExchange[, reasonPhrase]) Updates the response with the status code Forbidden, 403.
HttpExchange.notFound (httpExchange) Updates the response with the status code Not Found, 404.
HttpExchange.methodNotAllowed (httpExchange) Updates the response with the status code Method Not Allowed, 405.
HttpExchange.internalServerError (httpExchange) Updates the response with the status code Internal Server Error, 500.


Class HttpExchange

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

Returns:

    HttpContext the HTTP context.
httpExchange:getRequest ()
Returns the HTTP request.

Returns:

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

Returns:

    HttpResponse 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:onRequestBody ([buffer])
Returns a promise that resolves once the request body is available.

Parameters:

  • buffer boolean true to indicate that the request body must be bufferred. (optional)

Returns:

    jls.lang.Promise a promise that resolves once the request body is available.
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 (statusCode[, reasonPhrase[, body]])
Sets the status code for the response.

Parameters:

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

Parameters:

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

Parameters:

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

Parameters:

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

Parameters:

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

Parameters:

HttpExchange.internalServerError (httpExchange)
Updates the response with the status code Internal Server Error, 500.

Parameters:

generated by LDoc 1.4.6 Last updated 2022-01-22 16:32:56