Enum Class GeneratedResponses

java.lang.Object
java.lang.Enum<GeneratedResponses>
org.microproxy.GeneratedResponses
All Implemented Interfaces:
Serializable, Comparable<GeneratedResponses>, Constable

public enum GeneratedResponses extends Enum<GeneratedResponses>
How HttpFilters.proxyToClientResponse(org.microproxy.http.HttpObject) treats the responses the proxy answers with itself, rather than relaying a server's: its own error responses (the 502 for a server it cannot reach, the 504 for one that does not answer, a 400 for a bad request, the FailureResponder's and HttpFilters.proxyToServerFailure(org.microproxy.ProxyFailure)'s answers, ...), and the short-circuit responses a filter returned from an earlier hook (HttpFilters.clientToProxyRequest(org.microproxy.http.HttpObject), HttpFilters.proxyToServerRequest(org.microproxy.http.HttpObject)), the HttpCache's answers included. A field of a ProtocolPolicy (ProtocolPolicy.generatedResponses()).

Those responses reach no other response hook: HttpFilters.serverToProxyResponse(org.microproxy.http.HttpObject) sees only what comes from a server (and the 200 that opens a CONNECT tunnel). No filter sees the 407 authentication challenge in any mode: it is sent before the request's filters are made, as in LittleProxy. The 200 that opens a CONNECT tunnel and the 101 that accepts a CONNECT-UDP flow are not answers in this sense but the proxy's acceptance, which a filter may turn into a refusal (ProtocolPolicy.filterConnectAnswer() decides whether filters see the 200).

To change the proxy's own error pages, use a FailureResponder (or HttpFilters.proxyToServerFailure(org.microproxy.ProxyFailure)): it is asked for the answer to a failure, with the failure in hand, whatever this setting says. Inside the hook, FlowContext.responseSource() tells the proxy's and the filters' responses from the server's.

  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    proxyToClientResponse sees generated responses and may change them in place (headers, status, content), or return null to close the connection without an answer; a different object it returns is ignored (logged at DEBUG) and the generated response, with the changes made to it, is sent.
    proxyToClientResponse sees generated responses as it sees the server's, and may return another response to send instead, or null to close the connection without an answer.
    Generated responses never reach proxyToClientResponse: they are sent as made.
  • Method Summary

    Modifier and Type
    Method
    Description
    parse(String value)
    The value a configuration names: replaceable, in_place or skip (any case, - for _).
    Returns the enum constant of this class with the specified name.
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • REPLACEABLE

      public static final GeneratedResponses REPLACEABLE
      proxyToClientResponse sees generated responses as it sees the server's, and may return another response to send instead, or null to close the connection without an answer. The default, and LittleProxy 2.x's behaviour: ClientToProxyConnection.respondWithShortCircuitResponse writes the response the hook returns. Suits filters that brand every response the client gets: an error page of their own, a 503 with Retry-After in place of a 502, CORS or request-id headers on every response.
    • IN_PLACE

      public static final GeneratedResponses IN_PLACE
      proxyToClientResponse sees generated responses and may change them in place (headers, status, content), or return null to close the connection without an answer; a different object it returns is ignored (logged at DEBUG) and the generated response, with the changes made to it, is sent. So a filter written for the server's responses (one that answers some of them with a 400, say) cannot turn the proxy's own 502 for an unreachable server into something else. LittleProxy 1.x's behaviour, kept by forks descended from it: its ClientToProxyConnection.respondWithShortCircuitResponse runs the hook but writes the response it was given.
    • SKIP

      public static final GeneratedResponses SKIP
      Generated responses never reach proxyToClientResponse: they are sent as made. Trackers (ActivityTracker.responseSentToClient(org.microproxy.FlowContext, org.microproxy.http.HttpResponse)) and HttpFilters.proxyToClientResponseSent(org.microproxy.http.HttpResponse, org.microproxy.ResponseSource) still see them. For filters that must only ever see the server's responses.
  • Method Details

    • values

      public static GeneratedResponses[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static GeneratedResponses valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • parse

      public static GeneratedResponses parse(String value)
      The value a configuration names: replaceable, in_place or skip (any case, - for _).
      Parameters:
      value - the configuration value
      Returns:
      the value it names
      Throws:
      IllegalArgumentException - for any other value