Package akka.http.scaladsl.model
Class HttpRequest
- java.lang.Object
-
- akka.http.javadsl.model.HttpRequest
-
- akka.http.scaladsl.model.HttpRequest
-
- All Implemented Interfaces:
HttpMessage,HttpMessage.MessageTransformations<HttpRequest>,HttpMessage
public final class HttpRequest extends HttpRequest implements HttpMessage
The immutable model HTTP request model.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface akka.http.javadsl.model.HttpMessage
HttpMessage.DiscardedEntity, HttpMessage.MessageTransformations<Self>
-
Nested classes/interfaces inherited from interface akka.http.scaladsl.model.HttpMessage
HttpMessage.DiscardedEntity, HttpMessage.HttpMessageScalaDSLSugar, HttpMessage.HttpMessageScalaDSLSugar$
-
-
Constructor Summary
Constructors Constructor Description HttpRequest(HttpMethod method, Uri uri, scala.collection.immutable.Seq<HttpHeader> headers, RequestEntity entity, HttpProtocol protocol)Deprecated.use the constructor that includes an attributes parameter instead.HttpRequest(HttpMethod method, Uri uri, scala.collection.immutable.Seq<HttpHeader> headers, scala.collection.immutable.Map<AttributeKey<?>,java.lang.Object> attributes, RequestEntity entity, HttpProtocol protocol)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description HttpMethod_1()Uri_2()scala.collection.immutable.Seq<HttpHeader>_3()RequestEntity_4()HttpProtocol_5()static HttpRequestapply(HttpMethod method, Uri uri, scala.collection.immutable.Seq<HttpHeader> headers, RequestEntity entity, HttpProtocol protocol)scala.collection.immutable.Map<AttributeKey<?>,java.lang.Object>attributes()booleancanBeRetried()Determines whether this request can be safely retried, which is the case only of the request method is idempotent.scala.collection.immutable.Seq<HttpCookiePair>cookies()All cookies provided by the client in one or moreCookieheaders.HttpRequestcopy(HttpMethod method, Uri uri, scala.collection.immutable.Seq<HttpHeader> headers, RequestEntity entity, HttpProtocol protocol)Deprecated.Use the `withXYZ` methods instead.UrieffectiveUri(boolean securedConnection, Host defaultHostHeader)Resolve this request's URI according to the logic defined at http://tools.ietf.org/html/rfc7230#section-5.5RequestEntityentity()Returns the entity of this request.booleanequals(java.lang.Object obj)UrigetUri()Java APIinthashCode()scala.collection.immutable.Seq<HttpHeader>headers()booleanisRequest()Is this instance a request.booleanisResponse()Is this instance a response.HttpRequestmapEntity(scala.Function1<RequestEntity,RequestEntity> f)HttpMethodmethod()Returns the Http method of this request.HttpProtocolprotocol()The protocol of this message.HttpRequestself()java.lang.StringtoString()<M> HttpRequesttransformEntityDataBytes(akka.stream.Graph<akka.stream.FlowShape<akka.util.ByteString,akka.util.ByteString>,M> transformer)Returns a copy of Self message after applying the given transformationstatic OptHttpRequestunapply(HttpRequest any)Uriuri()static voidverifyUri(Uri uri)Verifies that the givenUriis non-empty and has either schemehttp,https,ws,wssor no scheme at all.HttpRequestwithAttributes(scala.collection.immutable.Map<AttributeKey<?>,java.lang.Object> attributes)Returns a copy of this message with the attributes set to the given ones.HttpRequestwithEffectiveUri(boolean securedConnection, Host defaultHostHeader)Returns a copy of this request with the URI resolved according to the logic defined at http://tools.ietf.org/html/rfc7230#section-5.5HttpRequestwithEntity(RequestEntity entity)Returns a copy of this instance with a new entity.HttpRequestwithEntity(RequestEntity entity)Returns a copy of this message with the entity set to the given one.HttpRequestwithHeaders(scala.collection.immutable.Seq<HttpHeader> headers)Returns a copy of this message with the list of headers set to the given ones.HttpRequestwithHeadersAndEntity(scala.collection.immutable.Seq<HttpHeader> headers, RequestEntity entity)Returns a copy of this message with the entity and headers set to the given ones.HttpRequestwithMethod(HttpMethod method)Returns a copy of this instance with a new method.HttpRequestwithProtocol(HttpProtocol protocol)Returns a copy of this message with a new protocol.HttpRequestwithUri(Uri uri)Java APIHttpRequestwithUri(Uri uri)HttpRequestwithUri(java.lang.String path)Returns a copy of this instance with a new Uri.-
Methods inherited from class akka.http.javadsl.model.HttpRequest
create, create, DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface akka.http.scaladsl.model.HttpMessage
addAttribute, addCredentials, addHeader, addHeaders, attribute, connectionCloseExpected, discardEntityBytes, discardEntityBytes, encoding, getAttribute, getHeader, getHeader, getHeaders, getHeaders, header, header, headers, mapAttributes, mapHeaders, removeAttribute, removeHeader, toStrict, toStrict, toStrict, toStrict, toStrict, toStrict, withDefaultHeaders, withDefaultHeaders, withEntity, withEntity, withEntity, withEntity, withEntity, withEntity, withEntity, withEntity, withHeaders, withHeaders
-
Methods inherited from interface akka.http.javadsl.model.HttpMessage.MessageTransformations
addAttribute, addCredentials, addHeader, addHeaders, removeAttribute, removeHeader, toStrict, toStrict, toStrict, toStrict, withEntity, withEntity, withEntity, withEntity, withEntity, withEntity, withEntity, withEntity, withHeaders
-
-
-
-
Constructor Detail
-
HttpRequest
public HttpRequest(HttpMethod method, Uri uri, scala.collection.immutable.Seq<HttpHeader> headers, scala.collection.immutable.Map<AttributeKey<?>,java.lang.Object> attributes, RequestEntity entity, HttpProtocol protocol)
-
HttpRequest
public HttpRequest(HttpMethod method, Uri uri, scala.collection.immutable.Seq<HttpHeader> headers, RequestEntity entity, HttpProtocol protocol)
Deprecated.use the constructor that includes an attributes parameter instead. Since 10.2.0.
-
-
Method Detail
-
verifyUri
public static void verifyUri(Uri uri)
Verifies that the givenUriis non-empty and has either schemehttp,https,ws,wssor no scheme at all. If any of these conditions is not met the method throws anIllegalUriException.- Parameters:
uri- (undocumented)
-
apply
public static HttpRequest apply(HttpMethod method, Uri uri, scala.collection.immutable.Seq<HttpHeader> headers, RequestEntity entity, HttpProtocol protocol)
-
unapply
public static OptHttpRequest unapply(HttpRequest any)
-
method
public HttpMethod method()
Description copied from class:HttpRequestReturns the Http method of this request.- Specified by:
methodin classHttpRequest
-
uri
public Uri uri()
-
headers
public scala.collection.immutable.Seq<HttpHeader> headers()
- Specified by:
headersin interfaceHttpMessage
-
attributes
public scala.collection.immutable.Map<AttributeKey<?>,java.lang.Object> attributes()
- Specified by:
attributesin interfaceHttpMessage
-
entity
public RequestEntity entity()
Description copied from class:HttpRequestReturns the entity of this request.- Specified by:
entityin interfaceHttpMessage- Specified by:
entityin interfaceHttpMessage- Specified by:
entityin classHttpRequest
-
protocol
public HttpProtocol protocol()
Description copied from interface:HttpMessageThe protocol of this message.- Specified by:
protocolin interfaceHttpMessage- Specified by:
protocolin interfaceHttpMessage
-
self
public HttpRequest self()
- Specified by:
selfin interfaceHttpMessage
-
isRequest
public boolean isRequest()
Description copied from interface:HttpMessageIs this instance a request.- Specified by:
isRequestin interfaceHttpMessage- Specified by:
isRequestin interfaceHttpMessage
-
isResponse
public boolean isResponse()
Description copied from interface:HttpMessageIs this instance a response.- Specified by:
isResponsein interfaceHttpMessage- Specified by:
isResponsein interfaceHttpMessage
-
effectiveUri
public Uri effectiveUri(boolean securedConnection, Host defaultHostHeader)
Resolve this request's URI according to the logic defined at http://tools.ietf.org/html/rfc7230#section-5.5Throws an
IllegalUriExceptionif the URI is relative and theheadersdon't include a validHostheader or if URI authority andHostheader don't match.- Parameters:
securedConnection- (undocumented)defaultHostHeader- (undocumented)- Returns:
- (undocumented)
-
withEffectiveUri
public HttpRequest withEffectiveUri(boolean securedConnection, Host defaultHostHeader)
Returns a copy of this request with the URI resolved according to the logic defined at http://tools.ietf.org/html/rfc7230#section-5.5- Parameters:
securedConnection- (undocumented)defaultHostHeader- (undocumented)- Returns:
- (undocumented)
-
cookies
public scala.collection.immutable.Seq<HttpCookiePair> cookies()
All cookies provided by the client in one or moreCookieheaders.- Returns:
- (undocumented)
-
canBeRetried
public boolean canBeRetried()
Determines whether this request can be safely retried, which is the case only of the request method is idempotent.- Returns:
- (undocumented)
-
withHeaders
public HttpRequest withHeaders(scala.collection.immutable.Seq<HttpHeader> headers)
Description copied from interface:HttpMessageReturns a copy of this message with the list of headers set to the given ones.- Specified by:
withHeadersin interfaceHttpMessage
-
withAttributes
public HttpRequest withAttributes(scala.collection.immutable.Map<AttributeKey<?>,java.lang.Object> attributes)
Description copied from interface:HttpMessageReturns a copy of this message with the attributes set to the given ones.- Specified by:
withAttributesin interfaceHttpMessage
-
withHeadersAndEntity
public HttpRequest withHeadersAndEntity(scala.collection.immutable.Seq<HttpHeader> headers, RequestEntity entity)
Description copied from interface:HttpMessageReturns a copy of this message with the entity and headers set to the given ones.- Specified by:
withHeadersAndEntityin interfaceHttpMessage
-
withEntity
public HttpRequest withEntity(RequestEntity entity)
Description copied from class:HttpRequestReturns a copy of this instance with a new entity.- Specified by:
withEntityin interfaceHttpMessage.MessageTransformations<HttpRequest>- Specified by:
withEntityin classHttpRequest
-
withEntity
public HttpRequest withEntity(RequestEntity entity)
Description copied from interface:HttpMessageReturns a copy of this message with the entity set to the given one.- Specified by:
withEntityin interfaceHttpMessage
-
mapEntity
public HttpRequest mapEntity(scala.Function1<RequestEntity,RequestEntity> f)
-
withMethod
public HttpRequest withMethod(HttpMethod method)
Description copied from class:HttpRequestReturns a copy of this instance with a new method.- Specified by:
withMethodin classHttpRequest
-
withProtocol
public HttpRequest withProtocol(HttpProtocol protocol)
Description copied from interface:HttpMessage.MessageTransformationsReturns a copy of this message with a new protocol.- Specified by:
withProtocolin interfaceHttpMessage.MessageTransformations<HttpRequest>
-
withUri
public HttpRequest withUri(java.lang.String path)
Description copied from class:HttpRequestReturns a copy of this instance with a new Uri.- Specified by:
withUriin classHttpRequest
-
withUri
public HttpRequest withUri(Uri uri)
-
transformEntityDataBytes
public <M> HttpRequest transformEntityDataBytes(akka.stream.Graph<akka.stream.FlowShape<akka.util.ByteString,akka.util.ByteString>,M> transformer)
Description copied from interface:HttpMessage.MessageTransformationsReturns a copy of Self message after applying the given transformation- Specified by:
transformEntityDataBytesin interfaceHttpMessage- Specified by:
transformEntityDataBytesin interfaceHttpMessage.MessageTransformations<HttpRequest>
-
getUri
public Uri getUri()
Java API- Specified by:
getUriin classHttpRequest
-
withUri
public HttpRequest withUri(Uri uri)
Java API- Specified by:
withUriin classHttpRequest
-
copy
public HttpRequest copy(HttpMethod method, Uri uri, scala.collection.immutable.Seq<HttpHeader> headers, RequestEntity entity, HttpProtocol protocol)
Deprecated.Use the `withXYZ` methods instead. Kept for binary compatibility. Since 10.2.0.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
_1
public HttpMethod _1()
-
_2
public Uri _2()
-
_3
public scala.collection.immutable.Seq<HttpHeader> _3()
-
_4
public RequestEntity _4()
-
_5
public HttpProtocol _5()
-
-