Interface FailureResponder

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface FailureResponder
Makes the proxy's own answer when a request fails (ProxyFailure), e.g. to send branded error pages or JSON instead of the default plain-text body. Install it with HttpProxyServerBootstrap.withFailureResponder(org.microproxy.FailureResponder).

Filters are asked first (HttpFilters.proxyToServerFailure(org.microproxy.ProxyFailure)); the responder is only consulted when none of them answers. Whatever it returns is framed by the proxy as usual: a Content-Length matching the body, the connection's keep-alive state, and no body for HEAD. The response then passes HttpFilters.proxyToClientResponse(org.microproxy.http.HttpObject) like the proxy's other responses.

The responder runs on the client connection's virtual thread and may be called concurrently for different connections. If it throws, the failure is logged and the default answer is sent.

  • Method Summary

    Modifier and Type
    Method
    Description
    respond(HttpRequest request, ProxyFailure failure)
    Returns the response for failure, or null for the proxy's default.
  • Method Details

    • respond

      HttpResponse respond(HttpRequest request, ProxyFailure failure)
      Returns the response for failure, or null for the proxy's default.
      Parameters:
      request - the request as the proxy was about to forward it (after filters and the proxy's own header changes); avoid echoing its parts into an HTML body unescaped
      failure - the proxy failure to answer
      Returns:
      the response to send, or null for the proxy default