Interface HttpMessage
-
- All Superinterfaces:
HttpMessage
- All Known Implementing Classes:
HttpRequest,HttpResponse
public interface HttpMessage extends HttpMessage
Common base class of HttpRequest and HttpResponse.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classHttpMessage.DiscardedEntityRepresents 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 classHttpMessage.HttpMessageScalaDSLSugarAdds Scala DSL idiomatic methods toHttpMessage, e.g. versions of methods with an implicitMaterializer.static classHttpMessage.HttpMessageScalaDSLSugar$-
Nested classes/interfaces inherited from interface akka.http.javadsl.model.HttpMessage
HttpMessage.MessageTransformations<Self>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> HttpMessageaddAttribute(AttributeKey<T> key, T value)HttpMessageaddCredentials(HttpCredentials credentials)HttpMessageaddHeader(HttpHeader header)Return a new instance with the given header added to the headers sequence.HttpMessageaddHeaders(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()booleanconnectionCloseExpected()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 responseHttpMessage.DiscardedEntitydiscardEntityBytes(akka.actor.ClassicActorSystemProvider system)Java APIHttpMessage.DiscardedEntitydiscardEntityBytes(akka.stream.Materializer mat)Discards the entities data bytes by running thedataBytesSource contained in this HttpMessage.HttpEncodingencoding()The content encoding as specified by the Content-Encoding header.ResponseEntityentity()The entity of this message.<T> java.util.Optional<T>getAttribute(AttributeKey<T> attributeKey)Java API<T extends HttpHeader>
java.util.Optional<T>getHeader(java.lang.Class<T> headerClass)Java APIjava.util.Optional<HttpHeader>getHeader(java.lang.String headerName)Java APIjava.lang.Iterable<HttpHeader>getHeaders()Java API<T extends HttpHeader>
java.lang.Iterable<T>getHeaders(java.lang.Class<T> headerClass)Java APIscala.Option<HttpHeader>header(java.lang.String headerName)<T extends HttpHeader>
scala.Option<T>header(scala.reflect.ClassTag<T> evidence$1)Returns the first header of the given type if there is onescala.collection.immutable.Seq<HttpHeader>headers()<T extends HttpHeader>
scala.collection.immutable.Seq<T>headers(scala.reflect.ClassTag<T> evidence$2)Returns all the headers of the given typebooleanisRequest()Is this instance a request.booleanisResponse()Is this instance a response.HttpMessagemapAttributes(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 functionHttpMessagemapHeaders(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 functionHttpProtocolprotocol()The protocol of this message.HttpMessageremoveAttribute(AttributeKey<?> key)HttpMessageremoveHeader(java.lang.String headerName)Removes the header with the given name (case-insensitive)HttpMessageself()java.util.concurrent.CompletionStage<HttpMessage>toStrict(long timeoutMillis, long maxBytes, akka.actor.ClassicActorSystemProvider system)Java APIjava.util.concurrent.CompletionStage<HttpMessage>toStrict(long timeoutMillis, long maxBytes, java.util.concurrent.Executor ec, akka.stream.Materializer materializer)Java APIjava.util.concurrent.CompletionStage<HttpMessage>toStrict(long timeoutMillis, akka.actor.ClassicActorSystemProvider system)Java APIjava.util.concurrent.CompletionStage<HttpMessage>toStrict(long timeoutMillis, java.util.concurrent.Executor ec, akka.stream.Materializer materializer)Java APIscala.concurrent.Future<HttpMessage>toStrict(scala.concurrent.duration.FiniteDuration timeout, long maxBytes, scala.concurrent.ExecutionContext ec, akka.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, scala.concurrent.ExecutionContext ec, akka.stream.Materializer fm)Returns a shareable and serializable copy of this message with a strict entity.<M> HttpMessagetransformEntityDataBytes(akka.stream.Graph<akka.stream.FlowShape<akka.util.ByteString,akka.util.ByteString>,M> transformer)HttpMessagewithAttributes(scala.collection.immutable.Map<AttributeKey<?>,java.lang.Object> headers)Returns a copy of this message with the attributes set to the given ones.HttpMessagewithDefaultHeaders(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.HttpMessagewithDefaultHeaders(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.HttpMessagewithEntity(byte[] bytes)HttpMessagewithEntity(ContentType.NonBinary contentType, java.lang.String string)HttpMessagewithEntity(ContentType contentType, byte[] bytes)HttpMessagewithEntity(ContentType contentType, akka.util.ByteString bytes)HttpMessagewithEntity(ContentType contentType, java.io.File file)HttpMessagewithEntity(ContentType contentType, java.nio.file.Path file)HttpMessagewithEntity(RequestEntity entity)Returns a copy of this message with the entity set to the given one.HttpMessagewithEntity(akka.util.ByteString bytes)HttpMessagewithEntity(java.lang.String string)HttpMessagewithHeaders(HttpHeader firstHeader, scala.collection.immutable.Seq<HttpHeader> otherHeaders)Returns a copy of this message with the list of headers set to the given ones.HttpMessagewithHeaders(java.lang.Iterable<HttpHeader> headers)Java APIHttpMessagewithHeaders(scala.collection.immutable.Seq<HttpHeader> headers)Returns a copy of this message with the list of headers set to the given ones.HttpMessagewithHeadersAndEntity(scala.collection.immutable.Seq<HttpHeader> headers, RequestEntity entity)Returns a copy of this message with the entity and headers set to the given ones.
-
-
-
Method Detail
-
self
HttpMessage self()
-
isRequest
boolean isRequest()
Description copied from interface:HttpMessageIs this instance a request.- Specified by:
isRequestin interfaceHttpMessage
-
isResponse
boolean isResponse()
Description copied from interface:HttpMessageIs this instance a response.- Specified by:
isResponsein interfaceHttpMessage
-
headers
scala.collection.immutable.Seq<HttpHeader> headers()
-
attributes
scala.collection.immutable.Map<AttributeKey<?>,java.lang.Object> attributes()
-
entity
ResponseEntity entity()
Description copied from interface:HttpMessageThe entity of this message.- Specified by:
entityin interfaceHttpMessage
-
protocol
HttpProtocol protocol()
Description copied from interface:HttpMessageThe protocol of this message.- Specified by:
protocolin interfaceHttpMessage
-
discardEntityBytes
HttpMessage.DiscardedEntity discardEntityBytes(akka.stream.Materializer mat)
Discards the entities data bytes by running thedataBytesSource contained in this HttpMessage.Note: It is crucial that entities are either discarded, or consumed by running the underlying
Sourceas 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.dataBytesmore 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
Strictentities 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.
- Specified by:
discardEntityBytesin interfaceHttpMessage- Parameters:
mat- (undocumented)- Returns:
- (undocumented)
-
discardEntityBytes
HttpMessage.DiscardedEntity discardEntityBytes(akka.actor.ClassicActorSystemProvider system)
Java API- Specified by:
discardEntityBytesin interfaceHttpMessage
-
withHeaders
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.
-
withHeaders
HttpMessage withHeaders(scala.collection.immutable.Seq<HttpHeader> headers)
Returns a copy of this message with the list of headers set to the given ones.
-
withDefaultHeaders
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.- Parameters:
firstHeader- (undocumented)otherHeaders- (undocumented)- Returns:
- (undocumented)
-
withDefaultHeaders
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.- Parameters:
defaultHeaders- (undocumented)- Returns:
- (undocumented)
-
withAttributes
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.
-
withEntity
HttpMessage withEntity(RequestEntity entity)
Returns a copy of this message with the entity set to the given one.
-
toStrict
scala.concurrent.Future<HttpMessage> toStrict(scala.concurrent.duration.FiniteDuration timeout, scala.concurrent.ExecutionContext ec, akka.stream.Materializer fm)
Returns a shareable and serializable copy of this message with a strict entity.
-
toStrict
scala.concurrent.Future<HttpMessage> toStrict(scala.concurrent.duration.FiniteDuration timeout, long maxBytes, scala.concurrent.ExecutionContext ec, akka.stream.Materializer fm)
Returns a shareable and serializable copy of this message with a strict entity.
-
withHeadersAndEntity
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.
-
mapHeaders
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
-
mapAttributes
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
-
encoding
HttpEncoding encoding()
The content encoding as specified by the Content-Encoding header. If no Content-Encoding header is present the default value 'identity' is returned.- Returns:
- (undocumented)
-
header
<T extends HttpHeader> scala.Option<T> header(scala.reflect.ClassTag<T> evidence$1)
Returns the first header of the given type if there is one- Parameters:
evidence$1- (undocumented)- Returns:
- (undocumented)
- Throws:
java.lang.IllegalArgumentException- if headerClass is a custom header.
-
header
scala.Option<HttpHeader> header(java.lang.String headerName)
-
headers
<T extends HttpHeader> scala.collection.immutable.Seq<T> headers(scala.reflect.ClassTag<T> evidence$2)
Returns all the headers of the given type
-
attribute
<T> scala.Option<T> attribute(AttributeKey<T> key, JavaMapping<AttributeKey<T>,AttributeKey<T>> ev)
-
connectionCloseExpected
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- Returns:
- (undocumented)
-
addHeader
HttpMessage addHeader(HttpHeader header)
Return a new instance with the given header added to the headers sequence. It's undefined where the header is added to the sequence
-
addAttribute
<T> HttpMessage addAttribute(AttributeKey<T> key, T value)
-
addCredentials
HttpMessage addCredentials(HttpCredentials credentials)
-
removeHeader
HttpMessage removeHeader(java.lang.String headerName)
Removes the header with the given name (case-insensitive)
-
removeAttribute
HttpMessage removeAttribute(AttributeKey<?> key)
-
withEntity
HttpMessage withEntity(java.lang.String string)
-
withEntity
HttpMessage withEntity(byte[] bytes)
-
withEntity
HttpMessage withEntity(akka.util.ByteString bytes)
-
withEntity
HttpMessage withEntity(ContentType.NonBinary contentType, java.lang.String string)
-
withEntity
HttpMessage withEntity(ContentType contentType, byte[] bytes)
-
withEntity
HttpMessage withEntity(ContentType contentType, akka.util.ByteString bytes)
-
withEntity
HttpMessage withEntity(ContentType contentType, java.io.File file)
-
withEntity
HttpMessage withEntity(ContentType contentType, java.nio.file.Path file)
-
transformEntityDataBytes
<M> HttpMessage transformEntityDataBytes(akka.stream.Graph<akka.stream.FlowShape<akka.util.ByteString,akka.util.ByteString>,M> transformer)
-
getHeaders
java.lang.Iterable<HttpHeader> getHeaders()
Java API- Specified by:
getHeadersin interfaceHttpMessage
-
getHeader
<T extends HttpHeader> java.util.Optional<T> getHeader(java.lang.Class<T> headerClass)
Java API- Specified by:
getHeaderin interfaceHttpMessage
-
getHeaders
<T extends HttpHeader> java.lang.Iterable<T> getHeaders(java.lang.Class<T> headerClass)
Java API- Specified by:
getHeadersin interfaceHttpMessage
-
getHeader
java.util.Optional<HttpHeader> getHeader(java.lang.String headerName)
Java API- Specified by:
getHeaderin interfaceHttpMessage
-
addHeaders
HttpMessage addHeaders(java.lang.Iterable<HttpHeader> headers)
Java API
-
withHeaders
HttpMessage withHeaders(java.lang.Iterable<HttpHeader> headers)
Java API
-
getAttribute
<T> java.util.Optional<T> getAttribute(AttributeKey<T> attributeKey)
Java API- Specified by:
getAttributein interfaceHttpMessage
-
toStrict
java.util.concurrent.CompletionStage<HttpMessage> toStrict(long timeoutMillis, java.util.concurrent.Executor ec, akka.stream.Materializer materializer)
Java API
-
toStrict
java.util.concurrent.CompletionStage<HttpMessage> toStrict(long timeoutMillis, long maxBytes, java.util.concurrent.Executor ec, akka.stream.Materializer materializer)
Java API
-
toStrict
java.util.concurrent.CompletionStage<HttpMessage> toStrict(long timeoutMillis, akka.actor.ClassicActorSystemProvider system)
Java API
-
toStrict
java.util.concurrent.CompletionStage<HttpMessage> toStrict(long timeoutMillis, long maxBytes, akka.actor.ClassicActorSystemProvider system)
Java API
-
-