Class HttpState

java.lang.Object
org.mockserver.mock.HttpState

public class HttpState extends Object
Author:
jamesdbloom
  • Field Details

  • Constructor Details

  • Method Details

    • setPort

      public static void setPort(HttpRequest request)
    • setPort

      public static void setPort(Integer port)
    • setPort

      public static void setPort(Integer... port)
    • setPort

      public static void setPort(List<Integer> port)
    • getPort

      public static Integer getPort()
    • getGrpcDescriptorStore

      public GrpcProtoDescriptorStore getGrpcDescriptorStore()
    • getFileStore

      public FileStore getFileStore()
    • getCrudDispatcher

      public CrudDispatcher getCrudDispatcher()
    • getControlPlaneAuthenticationHandler

      public AuthenticationHandler getControlPlaneAuthenticationHandler()
    • setControlPlaneAuthenticationHandler

      public void setControlPlaneAuthenticationHandler(AuthenticationHandler controlPlaneAuthenticationHandler)
    • getConfiguration

      public Configuration getConfiguration()
    • setLlmCompletionService

      public void setLlmCompletionService(LlmCompletionService llmCompletionService, LlmBackend llmBackend)
      Install the LLM completion service and default backend for runtime features that call out to an LLM (e.g. AI stub generation). Called by LifeCycle when a backend is configured; null-safe — when not called the stub generation endpoint falls back to template-based stubs.
    • getMockServerLogger

      public MockServerLogger getMockServerLogger()
    • clear

      public void clear(HttpRequest request)
    • reset

      public void reset()
    • add

      public List<Expectation> add(OpenAPIExpectation openAPIExpectation)
    • add

      public List<Expectation> add(Expectation... expectations)
    • firstMatchingExpectation

      public Expectation firstMatchingExpectation(RequestDefinition request)
    • peekFirstMatchingExpectation

      public Expectation peekFirstMatchingExpectation(RequestDefinition request)
      Side-effect-free probe: returns the first matching expectation WITHOUT consuming the match (no Times decrement, no scenario transition, no responseInProgress, no metrics). Note: the underlying matcher evaluation may still emit INFO-level EXPECTATION_MATCHED / EXPECTATION_NOT_MATCHED diagnostic logs; this method avoids the consuming side-effects only. Used by the gRPC bidi router to inspect the action type before committing to a handler — the real consuming match happens separately on the committed path.
    • firstMatchingEarlyExpectation

      public Expectation firstMatchingEarlyExpectation(HttpRequest headersOnly)
      Returns the first expectation whose matcher has respondBeforeBody=true, has no body matcher, and matches the supplied headers-only request. Used by the early-response path that runs before the request body is aggregated.
    • allMatchingExpectation

      public List<Expectation> allMatchingExpectation(HttpRequest request)
    • postProcess

      public void postProcess(Expectation expectation)
    • findClosestMatchDiff

      public Map<MatchDifference.Field,List<String>> findClosestMatchDiff(HttpRequest request)
    • debugMismatch

      public HttpResponse debugMismatch(HttpRequest request)
    • explainUnmatched

      public HttpResponse explainUnmatched(HttpRequest request)
      Retrieves recent requests that matched no expectation and, for each, computes ranked closest-expectation diagnostics with remediation hints.
      Parameters:
      request - the control-plane request (body may contain {"limit":N})
      Returns:
      a JSON response containing an array of unmatched requests with diagnostics
    • log

      public void log(LogEntry logEntry)
    • retrieve

      public HttpResponse retrieve(HttpRequest request)
    • verify

      public Future<String> verify(Verification verification)
    • verify

      public void verify(Verification verification, Consumer<String> resultConsumer)
    • verify

      public Future<String> verify(VerificationSequence verification)
    • verify

      public void verify(VerificationSequence verificationSequence, Consumer<String> resultConsumer)
    • handle

      public boolean handle(HttpRequest request, ResponseWriter responseWriter, boolean warDeployment)
    • getWebSocketClientRegistry

      public WebSocketClientRegistry getWebSocketClientRegistry()
    • getRequestMatchers

      public RequestMatchers getRequestMatchers()
    • getMockServerLog

      public MockServerEventLog getMockServerLog()
    • getScheduler

      public Scheduler getScheduler()
    • getUniqueLoopPreventionHeaderName

      public String getUniqueLoopPreventionHeaderName()
    • getUniqueLoopPreventionHeaderValue

      public String getUniqueLoopPreventionHeaderValue()
    • stop

      public void stop()
    • getStateBackend

      public StateBackend getStateBackend()
      Returns the pluggable state backend (G10 phase 2a). The default implementation is in-memory with zero behaviour change.