public interface HttpMessage extends HttpMessage
Modifier and Type | Interface and Description |
---|---|
static class |
HttpMessage.DiscardedEntity
Represents the currently being-drained HTTP Entity which triggers completion of the contained
Future once the entity has been drained for the given HttpMessage completely.
|
static class |
HttpMessage.HttpMessageScalaDSLSugar
Adds Scala DSL idiomatic methods to
HttpMessage , e.g. versions of methods with an implicit Materializer . |
static class |
HttpMessage.HttpMessageScalaDSLSugar$ |
HttpMessage.MessageTransformations<Self>
Modifier and Type | Method and Description |
---|---|
<T> HttpMessage |
addAttribute(AttributeKey<T> key,
T value) |
HttpMessage |
addCredentials(HttpCredentials credentials) |
HttpMessage |
addHeader(HttpHeader header)
Return a new instance with the given header added to the headers sequence.
|
HttpMessage |
addHeaders(java.lang.Iterable<HttpHeader> headers)
Java API
|
<T> scala.Option<T> |
attribute(AttributeKey<T> key,
JavaMapping<AttributeKey<T>,AttributeKey<T>> ev) |
scala.collection.immutable.Map<AttributeKey<?>,java.lang.Object> |
attributes() |
boolean |
connectionCloseExpected()
Returns true if this message is an:
- HttpRequest and the client does not want to reuse the connection after the response for this request has been received
- HttpResponse and the server will close the connection after this response
|
HttpMessage.DiscardedEntity |
discardEntityBytes(org.apache.pekko.actor.ClassicActorSystemProvider system)
Java API
|
HttpMessage.DiscardedEntity |
discardEntityBytes(org.apache.pekko.stream.Materializer mat)
Discards the entities data bytes by running the
dataBytes Source contained in this HttpMessage. |
HttpEncoding |
encoding()
The content encoding as specified by the Content-Encoding header.
|
ResponseEntity |
entity()
The entity of this message.
|
<T> java.util.Optional<T> |
getAttribute(AttributeKey<T> attributeKey)
Java API
|
<T extends HttpHeader> |
getHeader(java.lang.Class<T> headerClass)
Java API
|
java.util.Optional<HttpHeader> |
getHeader(java.lang.String headerName)
Java API
|
java.lang.Iterable<HttpHeader> |
getHeaders()
Java API
|
<T extends HttpHeader> |
getHeaders(java.lang.Class<T> headerClass)
Java API
|
<T extends HttpHeader> |
header(scala.reflect.ClassTag<T> evidence$1)
Returns the first header of the given type if there is one
|
scala.collection.immutable.Seq<HttpHeader> |
headers() |
<T extends HttpHeader> |
headers(scala.reflect.ClassTag<T> evidence$2)
Returns all the headers of the given type *
|
boolean |
isRequest()
Is this instance a request.
|
boolean |
isResponse()
Is this instance a response.
|
HttpMessage |
mapAttributes(scala.Function1<scala.collection.immutable.Map<AttributeKey<?>,java.lang.Object>,scala.collection.immutable.Map<AttributeKey<?>,java.lang.Object>> f)
Returns a copy of this message with the attributes transformed by the given function
|
HttpMessage |
mapHeaders(scala.Function1<scala.collection.immutable.Seq<HttpHeader>,scala.collection.immutable.Seq<HttpHeader>> f)
Returns a copy of this message with the list of headers transformed by the given function
|
HttpProtocol |
protocol()
The protocol of this message.
|
HttpMessage |
removeAttribute(AttributeKey<?> key) |
HttpMessage |
removeHeader(java.lang.String headerName)
Removes the header with the given name (case-insensitive)
|
HttpMessage |
self() |
scala.concurrent.Future<HttpMessage> |
toStrict(scala.concurrent.duration.FiniteDuration timeout,
scala.concurrent.ExecutionContext ec,
org.apache.pekko.stream.Materializer fm)
Returns a shareable and serializable copy of this message with a strict entity.
|
scala.concurrent.Future<HttpMessage> |
toStrict(scala.concurrent.duration.FiniteDuration timeout,
long maxBytes,
scala.concurrent.ExecutionContext ec,
org.apache.pekko.stream.Materializer fm)
Returns a shareable and serializable copy of this message with a strict entity.
|
java.util.concurrent.CompletionStage<HttpMessage> |
toStrict(long timeoutMillis,
org.apache.pekko.actor.ClassicActorSystemProvider system)
Java API
|
java.util.concurrent.CompletionStage<HttpMessage> |
toStrict(long timeoutMillis,
java.util.concurrent.Executor ec,
org.apache.pekko.stream.Materializer materializer)
Java API
|
java.util.concurrent.CompletionStage<HttpMessage> |
toStrict(long timeoutMillis,
long maxBytes,
org.apache.pekko.actor.ClassicActorSystemProvider system)
Java API
|
java.util.concurrent.CompletionStage<HttpMessage> |
toStrict(long timeoutMillis,
long maxBytes,
java.util.concurrent.Executor ec,
org.apache.pekko.stream.Materializer materializer)
Java API
|
<M> HttpMessage |
transformEntityDataBytes(org.apache.pekko.stream.Graph<org.apache.pekko.stream.FlowShape<org.apache.pekko.util.ByteString,org.apache.pekko.util.ByteString>,M> transformer) |
HttpMessage |
withAttributes(scala.collection.immutable.Map<AttributeKey<?>,java.lang.Object> headers)
Returns a copy of this message with the attributes set to the given ones.
|
HttpMessage |
withDefaultHeaders(HttpHeader firstHeader,
scala.collection.immutable.Seq<HttpHeader> otherHeaders)
Returns a new message that contains all of the given default headers which didn't already
exist (by case-insensitive header name) in this message.
|
HttpMessage |
withDefaultHeaders(scala.collection.immutable.Seq<HttpHeader> defaultHeaders)
Returns a new message that contains all of the given default headers which didn't already
exist (by case-insensitive header name) in this message.
|
HttpMessage |
withEntity(byte[] bytes) |
HttpMessage |
withEntity(org.apache.pekko.util.ByteString bytes) |
HttpMessage |
withEntity(ContentType.NonBinary contentType,
java.lang.String string) |
HttpMessage |
withEntity(ContentType contentType,
byte[] bytes) |
HttpMessage |
withEntity(ContentType contentType,
org.apache.pekko.util.ByteString bytes) |
HttpMessage |
withEntity(ContentType contentType,
java.io.File file) |
HttpMessage |
withEntity(ContentType contentType,
java.nio.file.Path file) |
HttpMessage |
withEntity(RequestEntity entity)
Returns a copy of this message with the entity set to the given one.
|
HttpMessage |
withEntity(java.lang.String string) |
HttpMessage |
withHeaders(HttpHeader firstHeader,
scala.collection.immutable.Seq<HttpHeader> otherHeaders)
Returns a copy of this message with the list of headers set to the given ones.
|
HttpMessage |
withHeaders(java.lang.Iterable<HttpHeader> headers)
Java API
|
HttpMessage |
withHeaders(scala.collection.immutable.Seq<HttpHeader> headers)
Returns a copy of this message with the list of headers set to the given ones.
|
HttpMessage |
withHeadersAndEntity(scala.collection.immutable.Seq<HttpHeader> headers,
RequestEntity entity)
Returns a copy of this message with the entity and headers set to the given ones.
|
HttpMessage self()
boolean isRequest()
HttpMessage
isRequest
in interface HttpMessage
boolean isResponse()
HttpMessage
isResponse
in interface HttpMessage
scala.collection.immutable.Seq<HttpHeader> headers()
scala.collection.immutable.Map<AttributeKey<?>,java.lang.Object> attributes()
ResponseEntity entity()
HttpMessage
entity
in interface HttpMessage
HttpProtocol protocol()
HttpMessage
protocol
in interface HttpMessage
HttpMessage.DiscardedEntity discardEntityBytes(org.apache.pekko.stream.Materializer mat)
dataBytes
Source contained in this HttpMessage.
Note: It is crucial that entities are either discarded, or consumed by running the underlying pekko.stream.scaladsl.Source
as otherwise the lack of consuming of the data will trigger back-pressure to the underlying TCP connection
(as designed), however possibly leading to an idle-timeout that will close the connection, instead of
just having ignored the data.
Warning: It is not allowed to discard and/or consume the entity.dataBytes
more than once
as the stream is directly attached to the "live" incoming data source from the underlying TCP connection.
Allowing it to be consumable twice would require buffering the incoming data, thus defeating the purpose
of its streaming nature. If the dataBytes source is materialized a second time, it will fail with an
"stream can cannot be materialized more than once" exception.
When called on Strict
entities or sources whose values can be buffered in memory,
the above warnings can be ignored. Repeated materialization is not necessary in this case, avoiding
the mentioned exceptions due to the data being held in memory.
In future versions, more automatic ways to warn or resolve these situations may be introduced, see issue #18716.
discardEntityBytes
in interface HttpMessage
mat
- (undocumented)HttpMessage.DiscardedEntity discardEntityBytes(org.apache.pekko.actor.ClassicActorSystemProvider system)
discardEntityBytes
in interface HttpMessage
HttpMessage withHeaders(HttpHeader firstHeader, scala.collection.immutable.Seq<HttpHeader> otherHeaders)
HttpMessage withHeaders(scala.collection.immutable.Seq<HttpHeader> headers)
HttpMessage withDefaultHeaders(HttpHeader firstHeader, scala.collection.immutable.Seq<HttpHeader> otherHeaders)
firstHeader
- (undocumented)otherHeaders
- (undocumented)HttpMessage withDefaultHeaders(scala.collection.immutable.Seq<HttpHeader> defaultHeaders)
defaultHeaders
- (undocumented)HttpMessage withAttributes(scala.collection.immutable.Map<AttributeKey<?>,java.lang.Object> headers)
HttpMessage withEntity(RequestEntity entity)
scala.concurrent.Future<HttpMessage> toStrict(scala.concurrent.duration.FiniteDuration timeout, scala.concurrent.ExecutionContext ec, org.apache.pekko.stream.Materializer fm)
scala.concurrent.Future<HttpMessage> toStrict(scala.concurrent.duration.FiniteDuration timeout, long maxBytes, scala.concurrent.ExecutionContext ec, org.apache.pekko.stream.Materializer fm)
HttpMessage withHeadersAndEntity(scala.collection.immutable.Seq<HttpHeader> headers, RequestEntity entity)
HttpMessage mapHeaders(scala.Function1<scala.collection.immutable.Seq<HttpHeader>,scala.collection.immutable.Seq<HttpHeader>> f)
HttpMessage mapAttributes(scala.Function1<scala.collection.immutable.Map<AttributeKey<?>,java.lang.Object>,scala.collection.immutable.Map<AttributeKey<?>,java.lang.Object>> f)
HttpEncoding encoding()
<T extends HttpHeader> scala.Option<T> header(scala.reflect.ClassTag<T> evidence$1)
<T extends HttpHeader> scala.collection.immutable.Seq<T> headers(scala.reflect.ClassTag<T> evidence$2)
<T> scala.Option<T> attribute(AttributeKey<T> key, JavaMapping<AttributeKey<T>,AttributeKey<T>> ev)
boolean connectionCloseExpected()
HttpMessage addHeader(HttpHeader header)
<T> HttpMessage addAttribute(AttributeKey<T> key, T value)
HttpMessage addCredentials(HttpCredentials credentials)
HttpMessage removeHeader(java.lang.String headerName)
HttpMessage removeAttribute(AttributeKey<?> key)
HttpMessage withEntity(java.lang.String string)
HttpMessage withEntity(byte[] bytes)
HttpMessage withEntity(org.apache.pekko.util.ByteString bytes)
HttpMessage withEntity(ContentType.NonBinary contentType, java.lang.String string)
HttpMessage withEntity(ContentType contentType, byte[] bytes)
HttpMessage withEntity(ContentType contentType, org.apache.pekko.util.ByteString bytes)
HttpMessage withEntity(ContentType contentType, java.io.File file)
HttpMessage withEntity(ContentType contentType, java.nio.file.Path file)
<M> HttpMessage transformEntityDataBytes(org.apache.pekko.stream.Graph<org.apache.pekko.stream.FlowShape<org.apache.pekko.util.ByteString,org.apache.pekko.util.ByteString>,M> transformer)
java.lang.Iterable<HttpHeader> getHeaders()
getHeaders
in interface HttpMessage
<T extends HttpHeader> java.util.Optional<T> getHeader(java.lang.Class<T> headerClass)
getHeader
in interface HttpMessage
<T extends HttpHeader> java.lang.Iterable<T> getHeaders(java.lang.Class<T> headerClass)
getHeaders
in interface HttpMessage
java.util.Optional<HttpHeader> getHeader(java.lang.String headerName)
getHeader
in interface HttpMessage
HttpMessage addHeaders(java.lang.Iterable<HttpHeader> headers)
HttpMessage withHeaders(java.lang.Iterable<HttpHeader> headers)
<T> java.util.Optional<T> getAttribute(AttributeKey<T> attributeKey)
getAttribute
in interface HttpMessage
java.util.concurrent.CompletionStage<HttpMessage> toStrict(long timeoutMillis, java.util.concurrent.Executor ec, org.apache.pekko.stream.Materializer materializer)
java.util.concurrent.CompletionStage<HttpMessage> toStrict(long timeoutMillis, long maxBytes, java.util.concurrent.Executor ec, org.apache.pekko.stream.Materializer materializer)
java.util.concurrent.CompletionStage<HttpMessage> toStrict(long timeoutMillis, org.apache.pekko.actor.ClassicActorSystemProvider system)
java.util.concurrent.CompletionStage<HttpMessage> toStrict(long timeoutMillis, long maxBytes, org.apache.pekko.actor.ClassicActorSystemProvider system)