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 HttpRequest
apply(HttpMethod method, Uri uri, scala.collection.immutable.Seq<HttpHeader> headers, RequestEntity entity, HttpProtocol protocol)
scala.collection.immutable.Map<AttributeKey<?>,java.lang.Object>
attributes()
boolean
canBeRetried()
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 moreCookie
headers.HttpRequest
copy(HttpMethod method, Uri uri, scala.collection.immutable.Seq<HttpHeader> headers, RequestEntity entity, HttpProtocol protocol)
Deprecated.Use the `withXYZ` methods instead.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.5RequestEntity
entity()
Returns the entity of this request.boolean
equals(java.lang.Object obj)
Uri
getUri()
Java APIint
hashCode()
scala.collection.immutable.Seq<HttpHeader>
headers()
boolean
isRequest()
Is this instance a request.boolean
isResponse()
Is this instance a response.HttpRequest
mapEntity(scala.Function1<RequestEntity,RequestEntity> f)
HttpMethod
method()
Returns the Http method of this request.HttpProtocol
protocol()
The protocol of this message.HttpRequest
self()
java.lang.String
toString()
<M> HttpRequest
transformEntityDataBytes(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 OptHttpRequest
unapply(HttpRequest any)
Uri
uri()
static void
verifyUri(Uri uri)
Verifies that the givenUri
is non-empty and has either schemehttp
,https
,ws
,wss
or no scheme at all.HttpRequest
withAttributes(scala.collection.immutable.Map<AttributeKey<?>,java.lang.Object> attributes)
Returns a copy of this message with the attributes set to the given ones.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.5HttpRequest
withEntity(RequestEntity entity)
Returns a copy of this instance with a new entity.HttpRequest
withEntity(RequestEntity entity)
Returns a copy of this message with the entity set to the given one.HttpRequest
withHeaders(scala.collection.immutable.Seq<HttpHeader> headers)
Returns a copy of this message with the list of headers set to the given ones.HttpRequest
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.HttpRequest
withMethod(HttpMethod method)
Returns a copy of this instance with a new method.HttpRequest
withProtocol(HttpProtocol protocol)
Returns a copy of this message with a new protocol.HttpRequest
withUri(Uri uri)
Java APIHttpRequest
withUri(Uri uri)
HttpRequest
withUri(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 givenUri
is non-empty and has either schemehttp
,https
,ws
,wss
or 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:HttpRequest
Returns the Http method of this request.- Specified by:
method
in classHttpRequest
-
uri
public Uri uri()
-
headers
public scala.collection.immutable.Seq<HttpHeader> headers()
- Specified by:
headers
in interfaceHttpMessage
-
attributes
public scala.collection.immutable.Map<AttributeKey<?>,java.lang.Object> attributes()
- Specified by:
attributes
in interfaceHttpMessage
-
entity
public RequestEntity entity()
Description copied from class:HttpRequest
Returns the entity of this request.- Specified by:
entity
in interfaceHttpMessage
- Specified by:
entity
in interfaceHttpMessage
- Specified by:
entity
in classHttpRequest
-
protocol
public HttpProtocol protocol()
Description copied from interface:HttpMessage
The protocol of this message.- Specified by:
protocol
in interfaceHttpMessage
- Specified by:
protocol
in interfaceHttpMessage
-
self
public HttpRequest self()
- Specified by:
self
in interfaceHttpMessage
-
isRequest
public boolean isRequest()
Description copied from interface:HttpMessage
Is this instance a request.- Specified by:
isRequest
in interfaceHttpMessage
- Specified by:
isRequest
in interfaceHttpMessage
-
isResponse
public boolean isResponse()
Description copied from interface:HttpMessage
Is this instance a response.- Specified by:
isResponse
in interfaceHttpMessage
- Specified by:
isResponse
in 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
IllegalUriException
if the URI is relative and theheaders
don't include a validHost
header or if URI authority andHost
header 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 moreCookie
headers.- 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:HttpMessage
Returns a copy of this message with the list of headers set to the given ones.- Specified by:
withHeaders
in interfaceHttpMessage
-
withAttributes
public HttpRequest withAttributes(scala.collection.immutable.Map<AttributeKey<?>,java.lang.Object> attributes)
Description copied from interface:HttpMessage
Returns a copy of this message with the attributes set to the given ones.- Specified by:
withAttributes
in interfaceHttpMessage
-
withHeadersAndEntity
public HttpRequest withHeadersAndEntity(scala.collection.immutable.Seq<HttpHeader> headers, RequestEntity entity)
Description copied from interface:HttpMessage
Returns a copy of this message with the entity and headers set to the given ones.- Specified by:
withHeadersAndEntity
in interfaceHttpMessage
-
withEntity
public HttpRequest withEntity(RequestEntity entity)
Description copied from class:HttpRequest
Returns a copy of this instance with a new entity.- Specified by:
withEntity
in interfaceHttpMessage.MessageTransformations<HttpRequest>
- Specified by:
withEntity
in classHttpRequest
-
withEntity
public HttpRequest withEntity(RequestEntity entity)
Description copied from interface:HttpMessage
Returns a copy of this message with the entity set to the given one.- Specified by:
withEntity
in interfaceHttpMessage
-
mapEntity
public HttpRequest mapEntity(scala.Function1<RequestEntity,RequestEntity> f)
-
withMethod
public HttpRequest withMethod(HttpMethod method)
Description copied from class:HttpRequest
Returns a copy of this instance with a new method.- Specified by:
withMethod
in classHttpRequest
-
withProtocol
public HttpRequest withProtocol(HttpProtocol protocol)
Description copied from interface:HttpMessage.MessageTransformations
Returns a copy of this message with a new protocol.- Specified by:
withProtocol
in interfaceHttpMessage.MessageTransformations<HttpRequest>
-
withUri
public HttpRequest withUri(java.lang.String path)
Description copied from class:HttpRequest
Returns a copy of this instance with a new Uri.- Specified by:
withUri
in 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.MessageTransformations
Returns a copy of Self message after applying the given transformation- Specified by:
transformEntityDataBytes
in interfaceHttpMessage
- Specified by:
transformEntityDataBytes
in interfaceHttpMessage.MessageTransformations<HttpRequest>
-
getUri
public Uri getUri()
Java API- Specified by:
getUri
in classHttpRequest
-
withUri
public HttpRequest withUri(Uri uri)
Java API- Specified by:
withUri
in 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:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in 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()
-
-