Class HttpRequestResult
HttpServer (both logical response and bytes to be sent over the wire), used for integration testing via Simulator.performHttpRequest(Request).
Instances can be acquired via the withMarshaledResponse(MarshaledResponse) builder factory method.
A convenience instance factory is also available via fromMarshaledResponse(MarshaledResponse).
This type is also delivered to the response consumers of HttpServer.RequestHandler
and SseServer.RequestHandler. Custom SSE transports use getSseHandshakeResult()
to obtain the logical handshake and any accepted client initializer or client context.
The Server-Sent Event equivalent of this type is SseRequestResult, which is used for integration testing via Simulator.performSseRequest(Request).
See https://www.soklet.com/docs/testing#integration-testing for detailed documentation.
- Author:
- Mark Allen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder used to construct instances ofHttpRequestResultviawithMarshaledResponse(MarshaledResponse).static final classBuilder used to copy instances ofHttpRequestResultviacopy(). -
Method Summary
Modifier and TypeMethodDescriptioncopy()Vends a mutable copier seeded with this instance's data, suitable for building new instances.booleanstatic @NonNull HttpRequestResultfromMarshaledResponse(@NonNull MarshaledResponse marshaledResponse) Creates aHttpRequestResultfrom a marshaled response without additional customization.The CORS preflight logical response, if applicable for the request.The request after request-interceptor rewriting for an SSE handshake.The final representation of the response to be written over the wire.The Resource Method that handled the request, if available.The logical response, determined by the return value of the Resource Method (if available).Returns the logical SSE handshake result, if request processing produced one.inthashCode()toString()withMarshaledResponse(@NonNull MarshaledResponse marshaledResponse) Acquires a builder forHttpRequestResultinstances.
-
Method Details
-
withMarshaledResponse
public static @NonNull HttpRequestResult.Builder withMarshaledResponse(@NonNull MarshaledResponse marshaledResponse) Acquires a builder forHttpRequestResultinstances.- Parameters:
marshaledResponse- the bytes that will ultimately be written over the wire- Returns:
- the builder
-
fromMarshaledResponse
public static @NonNull HttpRequestResult fromMarshaledResponse(@NonNull MarshaledResponse marshaledResponse) Creates aHttpRequestResultfrom a marshaled response without additional customization.- Parameters:
marshaledResponse- the bytes that will ultimately be written over the wire- Returns:
- a
HttpRequestResultinstance
-
copy
Vends a mutable copier seeded with this instance's data, suitable for building new instances.- Returns:
- a copier for this instance
-
toString
-
equals
-
hashCode
-
getMarshaledResponse
The final representation of the response to be written over the wire.- Returns:
- the response to be written over the wire
-
getResponse
The logical response, determined by the return value of the Resource Method (if available).- Returns:
- the logical response
-
getCorsPreflightResponse
The CORS preflight logical response, if applicable for the request.- Returns:
- the CORS preflight logical response
-
getResourceMethod
The Resource Method that handled the request, if available.- Returns:
- the Resource Method that handled the request
-
getEffectiveSseRequest
The request after request-interceptor rewriting for an SSE handshake. Custom transports should use this request for routing broadcasts and client initialization.- Returns:
- the effective SSE request, or empty for results without an SSE dispatch
-
getSseHandshakeResult
Returns the logical SSE handshake result, if request processing produced one.Custom
SseServertransports use anSseHandshakeResult.Acceptedresult to retrieve itsclient initializerandclient context. Acceptance is the application's decision; it does not prove that response headers were written, initialization succeeded, or the connection joined a broadcaster. UsegetMarshaledResponse()for the offered HTTP response and honor the transport's framing, admission and shutdown requirements before activation.Reading this accessor does not invoke the initializer or activate a connection. Initializers and client contexts are application-owned references, not defensive copies. The transport owns invoking an initializer once after the accepted response is written, keeping initialization bounded, and preserving its context for that connection. Queued initialization writes and broadcaster activation must wait for successful initialization; failure or prior termination prevents activation. Callers own any retention, logging or disclosure of those references.
- Returns:
- the logical SSE handshake result, or
Optional.empty()when unavailable
-