Top Description Inners Fields Constructors Methods
org.eclipse.jetty.reactive.client

public Class ReactiveResponse

extends Object
Class Inheritance
Imports
java.nio.ByteBuffer, java.util.Locale, java.util.function.BiFunction, org.eclipse.jetty.client.Response, org.eclipse.jetty.http.HttpFields, .HttpHeader, org.eclipse.jetty.io.Content.Chunk, org.eclipse.jetty.reactive.client.internal.ByteBufferBufferingProcessor, .DiscardingProcessor, .ResultProcessor, .StringBufferingProcessor, .Transformer, org.reactivestreams.Publisher

A reactive wrapper over Jetty's HttpClient Response.

A ReactiveResponse is available as soon as the response headers arrived to the client. The response content is processed by a response content function specified in ReactiveRequest#response(BiFunction).

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ReactiveResponse.Content

Collects utility methods to process response content.

public static class
public static record
ReactiveResponse.Result<
the type of the response content
T
>

A record holding the ReactiveResponse and the response content.

Field Summary

Modifier and TypeField and Description
private String
private String
private final ReactiveRequest
private final Response

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the encoding specified by the Content-Type header
getEncoding
()

public HttpFields

Returns:

the HTTP response headers
getHeaders
()

public String

Returns:

the media type specified by the Content-Type header
getMediaType
()

public ReactiveRequest

Returns:

the ReactiveRequest correspondent to this response
getReactiveRequest
()

public Response

Returns:

the wrapped Jetty response
getResponse
()

public int

Returns:

the HTTP status code
getStatus
()

private void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

encodingback to summary
private String encoding
mediaTypeback to summary
private String mediaType
requestback to summary
private final ReactiveRequest request
responseback to summary
private final Response response

Constructor Detail

ReactiveResponseback to summary
public ReactiveResponse(ReactiveRequest request, Response response)

Method Detail

getEncodingback to summary
public String getEncoding()
Returns:String

the encoding specified by the Content-Type header

See Also
getMediaType()
getHeadersback to summary
public HttpFields getHeaders()
Returns:HttpFields

the HTTP response headers

getMediaTypeback to summary
public String getMediaType()
Returns:String

the media type specified by the Content-Type header

See Also
getEncoding()
getReactiveRequestback to summary
public ReactiveRequest getReactiveRequest()
Returns:ReactiveRequest

the ReactiveRequest correspondent to this response

getResponseback to summary
public Response getResponse()
Returns:Response

the wrapped Jetty response

getStatusback to summary
public int getStatus()
Returns:int

the HTTP status code

resolveContentTypeback to summary
private void resolveContentType()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.eclipse.jetty.reactive.client back to summary

public Class ReactiveResponse.Content

extends Object
Class Inheritance

Collects utility methods to process response content.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<ByteBuffer>>

Returns:

a response content processing function that converts the content to a ByteBuffer up to 2097152 bytes.
asByteBuffer
()

public static BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<ByteBuffer>>

Returns:

a response content processing function that converts the content to a ByteBuffer up to the specified maximum capacity in bytes.
asByteBuffer
(int maxCapacity)

public static BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<ReactiveResponse.Result<ByteBuffer>>>

Returns:

a response content processing function that converts the content to a ByteBuffer up to 2097152 bytes, and produces a Result with the ByteBuffer content.
asByteBufferResult
()

public static BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<ReactiveResponse.Result<ByteBuffer>>>

Returns:

a response content processing function that converts the content to a ByteBuffer up to the specified maximum capacity in bytes, and produces a Result with the ByteBuffer content.
asByteBufferResult
(int maxCapacity)

public static <
the type of the content
T
>
BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<ReactiveResponse.Result<T>>>

Returns:

a response content processing function that discards the content and produces a Result with a null content of the given type.
asDiscardResult
()

public static BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<String>>

Returns:

a response content processing function that converts the content to a string up to 2097152 bytes.
asString
()

public static BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<String>>

Returns:

a response content processing function that converts the content to a string up to the specified maximum capacity in bytes.
asString
(int maxCapacity)

public static BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<ReactiveResponse.Result<String>>>

Returns:

a response content processing function that converts the content to a string up to 2097152 bytes, and produces a Result with the string content.
asStringResult
()

public static BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<ReactiveResponse.Result<String>>>

Returns:

a response content processing function that converts the content to a string up to the specified maximum capacity in bytes, and produces a Result with the string content.
asStringResult
(int maxCapacity)

public static BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<ReactiveResponse>>

Returns:

a response content processing function that discards the content
discard
()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Contentback to summary
public Content()

Method Detail

asByteBufferback to summary
public static BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<ByteBuffer>> asByteBuffer()
Returns:BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<ByteBuffer>>

a response content processing function that converts the content to a ByteBuffer up to 2097152 bytes.

asByteBufferback to summary
public static BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<ByteBuffer>> asByteBuffer(int maxCapacity)
Returns:BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<ByteBuffer>>

a response content processing function that converts the content to a ByteBuffer up to the specified maximum capacity in bytes.

asByteBufferResultback to summary
public static BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<ReactiveResponse.Result<ByteBuffer>>> asByteBufferResult()
Returns:BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<ReactiveResponse.Result<ByteBuffer>>>

a response content processing function that converts the content to a ByteBuffer up to 2097152 bytes, and produces a Result with the ByteBuffer content.

asByteBufferResultback to summary
public static BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<ReactiveResponse.Result<ByteBuffer>>> asByteBufferResult(int maxCapacity)
Returns:BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<ReactiveResponse.Result<ByteBuffer>>>

a response content processing function that converts the content to a ByteBuffer up to the specified maximum capacity in bytes, and produces a Result with the ByteBuffer content.

asDiscardResultback to summary
public static <T> BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<ReactiveResponse.Result<T>>> asDiscardResult()
Parameters
<T>
the type of the content
Returns:BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<ReactiveResponse.Result<T>>>

a response content processing function that discards the content and produces a Result with a null content of the given type.

asStringback to summary
public static BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<String>> asString()
Returns:BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<String>>

a response content processing function that converts the content to a string up to 2097152 bytes.

asStringback to summary
public static BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<String>> asString(int maxCapacity)
Returns:BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<String>>

a response content processing function that converts the content to a string up to the specified maximum capacity in bytes.

asStringResultback to summary
public static BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<ReactiveResponse.Result<String>>> asStringResult()
Returns:BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<ReactiveResponse.Result<String>>>

a response content processing function that converts the content to a string up to 2097152 bytes, and produces a Result with the string content.

asStringResultback to summary
public static BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<ReactiveResponse.Result<String>>> asStringResult(int maxCapacity)
Returns:BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<ReactiveResponse.Result<String>>>

a response content processing function that converts the content to a string up to the specified maximum capacity in bytes, and produces a Result with the string content.

discardback to summary
public static BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<ReactiveResponse>> discard()
Returns:BiFunction<ReactiveResponse, Publisher<Content.Chunk>, Publisher<ReactiveResponse>>

a response content processing function that discards the content

org.eclipse.jetty.reactive.client back to summary

public Class ReactiveResponse.Event

extends Object
Class Inheritance

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Field Summary

Modifier and TypeField and Description
private final ByteBuffer
private final Throwable
private final ReactiveResponse
private final ReactiveResponse.Event.Type

Constructor Summary

AccessConstructor and Description
public
public
public
private

Method Summary

Modifier and TypeMethod and Description
public ByteBuffer

Returns:

the event content, or null if this is not a content event
getContent
()

public Throwable

Returns:

the event failure, or null if this is not a failure event
getFailure
()

public ReactiveResponse

Returns:

the response that generated this event
getResponse
()

public ReactiveResponse.Event.Type

Returns:

the event type
getType
()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contentback to summary
private final ByteBuffer content
failureback to summary
private final Throwable failure
responseback to summary
private final ReactiveResponse response
typeback to summary
private final ReactiveResponse.Event.Type type

Constructor Detail

Eventback to summary
public Event(ReactiveResponse.Event.Type type, ReactiveResponse response)
Eventback to summary
public Event(ReactiveResponse.Event.Type type, ReactiveResponse response, ByteBuffer content)
Eventback to summary
public Event(ReactiveResponse.Event.Type type, ReactiveResponse response, Throwable failure)
Eventback to summary
private Event(ReactiveResponse.Event.Type type, ReactiveResponse response, ByteBuffer content, Throwable failure)

Method Detail

getContentback to summary
public ByteBuffer getContent()
Returns:ByteBuffer

the event content, or null if this is not a content event

getFailureback to summary
public Throwable getFailure()
Returns:Throwable

the event failure, or null if this is not a failure event

getResponseback to summary
public ReactiveResponse getResponse()
Returns:ReactiveResponse

the response that generated this event

getTypeback to summary
public ReactiveResponse.Event.Type getType()
Returns:ReactiveResponse.Event.Type

the event type

org.eclipse.jetty.reactive.client back to summary

public final Enum ReactiveResponse.Event.Type

extends Enum<ReactiveResponse.Event.Type>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final ReactiveResponse.Event.Type
public static final ReactiveResponse.Event.Type
public static final ReactiveResponse.Event.Type
public static final ReactiveResponse.Event.Type
public static final ReactiveResponse.Event.Type
public static final ReactiveResponse.Event.Type

Constructor Summary

AccessConstructor and Description
private
Type()

Field Detail

BEGINback to summary
public static final ReactiveResponse.Event.Type BEGIN
COMPLETEback to summary
public static final ReactiveResponse.Event.Type COMPLETE
CONTENTback to summary
public static final ReactiveResponse.Event.Type CONTENT
FAILUREback to summary
public static final ReactiveResponse.Event.Type FAILURE
HEADERSback to summary
public static final ReactiveResponse.Event.Type HEADERS
SUCCESSback to summary
public static final ReactiveResponse.Event.Type SUCCESS

Constructor Detail

Typeback to summary
private Type()

Method Detail

valueOfback to summary
public static ReactiveResponse.Event.Type valueOf(String name)
valuesback to summary
public static ReactiveResponse.Event.Type[] values()
org.eclipse.jetty.reactive.client back to summary

public final Record ReactiveResponse.Result<T>

extends Record
Class Inheritance
Record Components
response:ReactiveResponse
the response
content:T
the response content
Type Parameters
<T>
the type of the response content

A record holding the ReactiveResponse and the response content.

Field Summary

Modifier and TypeField and Description
private final T
content

Record Component accessed by content().

the response content
private final ReactiveResponse
response

Record Component accessed by response().

the response

Constructor Summary

AccessConstructor and Description
public
Result(ReactiveResponse response, T content)

Method Summary

Modifier and TypeMethod and Description
public T
content()

Record Component getter of content.

Record Component the response content

public final boolean
equals(Object
the reference object with which to compare.
o
)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.
public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.
public ReactiveResponse
response()

Record Component getter of response.

Record Component the response

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

contentback to summary
private final T content

Record Component accessed by content().

the response content

responseback to summary
private final ReactiveResponse response

Record Component accessed by response().

the response

Constructor Detail

Resultback to summary
public Result(ReactiveResponse response, T content)

Method Detail

contentback to summary
public T content()

Record Component getter of content.

Record Component
the response content
equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this record is equal to the argument; false otherwise.

hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

Returns:int

a hash code value for this record.

responseback to summary
public ReactiveResponse response()

Record Component getter of response.

Record Component
the response
toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

Returns:String

a string representation of the object.