Interface HttpMessage
- All Superinterfaces:
- HttpMessage
- All Known Implementing Classes:
- HttpRequest,- HttpResponse
- 
Nested Class SummaryNested ClassesModifier and TypeInterfaceDescriptionstatic final classRepresents 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 final classAdds Scala DSL idiomatic methods toHttpMessage, e.g. versions of methods with an implicitMaterializer.static classNested classes/interfaces inherited from interface org.apache.pekko.http.javadsl.model.HttpMessageHttpMessage.MessageTransformations<Self>
- 
Method SummaryModifier and TypeMethodDescription<T> HttpMessageaddAttribute(AttributeKey<T> key, T value) addCredentials(HttpCredentials credentials) addHeader(HttpHeader header) Return a new instance with the given header added to the headers sequence.addHeaders(Iterable<HttpHeader> headers) Java API<T> scala.Option<T>attribute(AttributeKey<T> key, JavaMapping<AttributeKey<T>, AttributeKey<T>> ev) scala.collection.immutable.Map<AttributeKey<?>,Object> booleanReturns 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 responsediscardEntityBytes(org.apache.pekko.actor.ClassicActorSystemProvider system) Java APIdiscardEntityBytes(org.apache.pekko.stream.Materializer mat) Discards the entities data bytes by running thedataBytesSource contained in this HttpMessage.encoding()The content encoding as specified by the Content-Encoding header.entity()The entity of this message.<T> Optional<T>getAttribute(AttributeKey<T> attributeKey) Java API<T extends HttpHeader>
 Optional<T>Java APIJava APIJava API<T extends HttpHeader>
 Iterable<T>getHeaders(Class<T> headerClass) Java API<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 type *booleanIs this instance a request.booleanIs this instance a response.mapAttributes(scala.Function1<scala.collection.immutable.Map<AttributeKey<?>, Object>, scala.collection.immutable.Map<AttributeKey<?>, Object>> f) Returns a copy of this message with the attributes transformed by the given functionmapHeaders(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 functionprotocol()The protocol of this message.removeAttribute(AttributeKey<?> key) removeHeader(String headerName) Removes the header with the given name (case-insensitive)self()toStrict(long timeoutMillis, long maxBytes, Executor ec, org.apache.pekko.stream.Materializer materializer) Java APItoStrict(long timeoutMillis, long maxBytes, org.apache.pekko.actor.ClassicActorSystemProvider system) Java APIJava APItoStrict(long timeoutMillis, org.apache.pekko.actor.ClassicActorSystemProvider system) Java APIscala.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.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.<M> HttpMessagetransformEntityDataBytes(org.apache.pekko.stream.Graph<org.apache.pekko.stream.FlowShape<org.apache.pekko.util.ByteString, org.apache.pekko.util.ByteString>, M> transformer) withAttributes(scala.collection.immutable.Map<AttributeKey<?>, Object> headers) Returns a copy of this message with the attributes set to the given ones.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.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.withEntity(byte[] bytes) withEntity(String string) withEntity(ContentType.NonBinary contentType, String string) withEntity(ContentType contentType, byte[] bytes) withEntity(ContentType contentType, File file) withEntity(ContentType contentType, Path file) withEntity(ContentType contentType, org.apache.pekko.util.ByteString bytes) withEntity(RequestEntity entity) Returns a copy of this message with the entity set to the given one.withEntity(org.apache.pekko.util.ByteString bytes) withHeaders(Iterable<HttpHeader> headers) Java APIwithHeaders(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(scala.collection.immutable.Seq<HttpHeader> headers) Returns a copy of this message with the list of headers set to the given ones.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.
- 
Method Details- 
selfHttpMessage self()
- 
isRequestboolean isRequest()Description copied from interface:HttpMessageIs this instance a request.- Specified by:
- isRequestin interface- HttpMessage
 
- 
isResponseboolean isResponse()Description copied from interface:HttpMessageIs this instance a response.- Specified by:
- isResponsein interface- HttpMessage
 
- 
headersscala.collection.immutable.Seq<HttpHeader> headers()
- 
attributesscala.collection.immutable.Map<AttributeKey<?>,Object> attributes()
- 
entityResponseEntity entity()Description copied from interface:HttpMessageThe entity of this message.- Specified by:
- entityin interface- HttpMessage
 
- 
protocolHttpProtocol protocol()Description copied from interface:HttpMessageThe protocol of this message.- Specified by:
- protocolin interface- HttpMessage
 
- 
discardEntityBytesDiscards 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 pekko.stream.scaladsl.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 interface- HttpMessage
- Parameters:
- mat- (undocumented)
- Returns:
- (undocumented)
 
- 
discardEntityBytesHttpMessage.DiscardedEntity discardEntityBytes(org.apache.pekko.actor.ClassicActorSystemProvider system) Java API- Specified by:
- discardEntityBytesin interface- HttpMessage
 
- 
withHeadersHttpMessage 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.
- 
withHeadersReturns a copy of this message with the list of headers set to the given ones.
- 
withDefaultHeadersHttpMessage 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)
 
- 
withDefaultHeadersReturns 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)
 
- 
withAttributesReturns a copy of this message with the attributes set to the given ones.
- 
withEntityReturns a copy of this message with the entity set to the given one.
- 
toStrictscala.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.
- 
toStrictscala.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.
- 
withHeadersAndEntityHttpMessage 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.
- 
mapHeadersHttpMessage 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
- 
mapAttributesHttpMessage mapAttributes(scala.Function1<scala.collection.immutable.Map<AttributeKey<?>, Object>, scala.collection.immutable.Map<AttributeKey<?>, Object>> f) Returns a copy of this message with the attributes transformed by the given function
- 
encodingHttpEncoding 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)
 
- 
headerReturns the first header of the given type if there is one
- 
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
- 
connectionCloseExpectedboolean 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)
 
- 
addHeaderReturn a new instance with the given header added to the headers sequence. It's undefined where the header is added to the sequence
- 
addAttribute
- 
addCredentials
- 
removeHeaderRemoves the header with the given name (case-insensitive)
- 
removeAttribute
- 
withEntity
- 
withEntity
- 
withEntity
- 
withEntity
- 
withEntity
- 
withEntity
- 
withEntity
- 
withEntity
- 
transformEntityDataBytes<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) 
- 
getHeadersIterable<HttpHeader> getHeaders()Java API- Specified by:
- getHeadersin interface- HttpMessage
 
- 
getHeaderJava API- Specified by:
- getHeaderin interface- HttpMessage
 
- 
getHeadersJava API- Specified by:
- getHeadersin interface- HttpMessage
 
- 
getHeaderJava API- Specified by:
- getHeaderin interface- HttpMessage
 
- 
addHeadersJava API
- 
withHeadersJava API
- 
getAttributeJava API- Specified by:
- getAttributein interface- HttpMessage
 
- 
toStrictCompletionStage<HttpMessage> toStrict(long timeoutMillis, Executor ec, org.apache.pekko.stream.Materializer materializer) Java API
- 
toStrictCompletionStage<HttpMessage> toStrict(long timeoutMillis, long maxBytes, Executor ec, org.apache.pekko.stream.Materializer materializer) Java API
- 
toStrictCompletionStage<HttpMessage> toStrict(long timeoutMillis, org.apache.pekko.actor.ClassicActorSystemProvider system) Java API
- 
toStrictCompletionStage<HttpMessage> toStrict(long timeoutMillis, long maxBytes, org.apache.pekko.actor.ClassicActorSystemProvider system) Java API
 
-