Class EquinixResponse<T>
java.lang.Object
com.eqixiac.equinix.core.http.response.EquinixResponse<T>
Immutable view of a single HTTP exchange, exposing exactly what response handling needs: the
status line, a read-only case-insensitive snapshot of the response headers, and the body stream
with its declared length. No transport (Apache HttpClient) type appears in this class's API -
the HTTP client captures these values from the raw transport response at construction.
Note that getContent() exposes the one-shot connection-backed body stream: once the
SDK's response handling has consumed it (the normal case), it is exhausted/closed and cannot be
re-read. Reading the stream to end-of-stream (or calling drainQuietly()) releases the
pooled connection. The header map keeps a single value per header name (last one wins for
repeated headers such as Set-Cookie).
The type parameter T threads the operation's model type from the request through to
the response handlers; it carries no state here.
- Author:
- ianjones
-
Constructor Summary
ConstructorsConstructorDescriptionEquinixResponse(int statusCode, String statusText, Map<String, String> headers, InputStream content, long contentLength) Captures a response snapshot. -
Method Summary
Modifier and TypeMethodDescriptionvoidBest-effort consumes the body stream to end-of-stream and closes it, so the underlying pooled connection is released back to the connection manager.boolean
-
Constructor Details
-
EquinixResponse
public EquinixResponse(int statusCode, String statusText, Map<String, String> headers, InputStream content, long contentLength) Captures a response snapshot. Internal - constructed by the SDK's HTTP client from the raw transport response.- Parameters:
statusCode- the HTTP status codestatusText- the HTTP reason phrase (may benull)headers- the response headers (copied into a case-insensitive read-only map)content- the body stream, ornullwhen the response has no bodycontentLength- the declared body length; negative when unknown
-
-
Method Details
-
isSuccessful
public boolean isSuccessful()- Returns:
truefor a 2xx status
-
drainQuietly
public void drainQuietly()Best-effort consumes the body stream to end-of-stream and closes it, so the underlying pooled connection is released back to the connection manager. Used by response handlers that do not otherwise read the body; releasing a connection must never fail the call, so all errors are swallowed.
-