Class ClientRequest
- All Implemented Interfaces:
ClientRequestContext
,HttpHeaders
,HttpHeaders
,org.glassfish.jersey.internal.inject.InjectionManagerSupplier
,PropertiesResolver
- Author:
- Marek Potociar
-
Nested Class Summary
Nested classes/interfaces inherited from class org.glassfish.jersey.message.internal.OutboundMessageContext
OutboundMessageContext.StreamProvider
-
Field Summary
Fields inherited from interface jakarta.ws.rs.core.HttpHeaders
ACCEPT, ACCEPT_CHARSET, ACCEPT_ENCODING, ACCEPT_LANGUAGE, ALLOW, AUTHORIZATION, CACHE_CONTROL, CONTENT_DISPOSITION, CONTENT_ENCODING, CONTENT_ID, CONTENT_LANGUAGE, CONTENT_LENGTH, CONTENT_LOCATION, CONTENT_TYPE, COOKIE, DATE, ETAG, EXPIRES, HOST, IF_MATCH, IF_MODIFIED_SINCE, IF_NONE_MATCH, IF_UNMODIFIED_SINCE, LAST_EVENT_ID_HEADER, LAST_MODIFIED, LOCATION, RETRY_AFTER, SET_COOKIE, USER_AGENT, VARY, WWW_AUTHENTICATE
Fields inherited from interface org.glassfish.jersey.http.HttpHeaders
ACCEPT_PATCH, ACCEPT_RANGES, AGE, CONNECTION, CONTENT_RANGE, EXPECT, FORWARDED, FROM, IF_RANGE, LINK, MAX_FORWARDS, MIME_VERSION, ORIGIN, PROXY_AUTHENTICATE, PROXY_AUTHENTICATION_INFO, PROXY_AUTHORIZATION, PROXY_CONNECTION, RANGE, REFERER, SERVER, TE, TRAILER, TRANSFER_ENCODING, UPGRADE, VIA
-
Constructor Summary
ModifierConstructorDescriptionprotected
ClientRequest
(URI requestUri, ClientConfig clientConfig, PropertiesDelegate propertiesDelegate) Create new Jersey client request context.ClientRequest
(ClientRequest original) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
Add new accepted types to the message headers.void
Add new accepted types to the message headers.void
acceptLanguage
(String... locales) Add new accepted languages to the message headers.void
acceptLanguage
(Locale... locales) Add new accepted languages to the message headers.void
cacheControl
(CacheControl cacheControl) Add new cache control entry to the message headers.void
Add new cookie to the message headers.void
Enable a buffering of serialized entity.void
Set message encoding.Get the request filter chain aborting response if set, ornull
otherwise.The related client/server sideConfiguration
.org.glassfish.jersey.internal.inject.InjectionManager
Get injection manager.getProperty
(String name) Get reader interceptors of this request.getRequestHeader
(String name) Get the values of an HTTP request header if the header exists on the current request.getUri()
Get the message body workers associated with the request.Get writer interceptors of this request.boolean
hasProperty
(String name) boolean
Indicates whether the User-Agent header should be omitted if not directly set to the map of headers.void
ignoreUserAgent
(boolean ignore) Indicates whether the User-Agent header should be omitted if not directly set to the map of headers.boolean
Returns true if the request is called asynchronously usingAsyncInvoker
void
Set message language.void
Set message language.void
removeProperty
(String name) <T> T
resolveProperty
(String name, Class<T> type) Resolve a property value for the specified propertyname
.<T> T
resolveProperty
(String name, T defaultValue) Resolve a property value for the specified propertyname
.void
void
setProperty
(String name, Object object) void
void
setWorkers
(MessageBodyWorkers workers) Set the message body workers associated with the request.void
Set message content type.void
Set message content type.void
Set message content variant (type, language and encoding).void
Write (serialize) the entity set in this request into theentity stream
.Methods inherited from class org.glassfish.jersey.message.internal.OutboundMessageContext
close, commitStream, enableBuffering, getAcceptableLanguages, getAcceptableMediaTypes, getAllowedMethods, getDate, getEntity, getEntityAnnotations, getEntityClass, getEntityStream, getEntityTag, getEntityType, getHeaders, getHeaderString, getLanguage, getLastModified, getLength, getLengthLong, getLink, getLinkBuilder, getLinks, getLocation, getMediaType, getRequestCookies, getResponseCookies, getStringHeaders, hasEntity, hasLink, isCommitted, replaceHeaders, setEntity, setEntity, setEntity, setEntity, setEntityAnnotations, setEntityStream, setEntityType, setMediaType, setStreamProvider
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface jakarta.ws.rs.client.ClientRequestContext
getAcceptableLanguages, getAcceptableMediaTypes, getDate, getEntity, getEntityAnnotations, getEntityClass, getEntityStream, getEntityType, getHeaders, getHeaderString, getLanguage, getMediaType, getStringHeaders, hasEntity, setEntity, setEntity, setEntityStream
Methods inherited from interface jakarta.ws.rs.core.HttpHeaders
getAcceptableLanguages, getAcceptableMediaTypes, getDate, getHeaderString, getLanguage, getLength, getMediaType
-
Constructor Details
-
ClientRequest
protected ClientRequest(URI requestUri, ClientConfig clientConfig, PropertiesDelegate propertiesDelegate) Create new Jersey client request context.- Parameters:
requestUri
- request Uri.clientConfig
- request configuration.propertiesDelegate
- properties delegate.
-
ClientRequest
Copy constructor.- Parameters:
original
- original instance.
-
-
Method Details
-
resolveProperty
Description copied from interface:PropertiesResolver
Resolve a property value for the specified propertyname
.The method returns the value of the property registered in the request-specific property bag, if available. If no property for the given property name is found in the request-specific property bag, the method looks at the properties stored in the
global runtime configuration
this request belongs to. If there is a value defined in the runtime configuration, it is returned, otherwise the method returnsnull
if no such property is registered neither in the runtime nor in the request-specific property bag.- Specified by:
resolveProperty
in interfacePropertiesResolver
- Type Parameters:
T
- property Java type.- Parameters:
name
- property name.type
- expected property class type.- Returns:
- resolved property value or
null
if no such property is registered.
-
resolveProperty
Description copied from interface:PropertiesResolver
Resolve a property value for the specified propertyname
.The method returns the value of the property registered in the request-specific property bag, if available. If no property for the given property name is found in the request-specific property bag, the method looks at the properties stored in the
global runtime configuration
this request belongs to. If there is a value defined in the runtime configuration, it is returned, otherwise the method returnsdefaultValue
if no such property is registered neither in the runtime nor in the request-specific property bag.- Specified by:
resolveProperty
in interfacePropertiesResolver
- Type Parameters:
T
- property Java type.- Parameters:
name
- property name.defaultValue
- default value to return if the property is not registered.- Returns:
- resolved property value or
defaultValue
if no such property is registered.
-
hasProperty
- Specified by:
hasProperty
in interfaceClientRequestContext
-
getProperty
- Specified by:
getProperty
in interfaceClientRequestContext
-
getPropertyNames
- Specified by:
getPropertyNames
in interfaceClientRequestContext
-
setProperty
- Specified by:
setProperty
in interfaceClientRequestContext
-
removeProperty
- Specified by:
removeProperty
in interfaceClientRequestContext
-
getUri
- Specified by:
getUri
in interfaceClientRequestContext
-
setUri
- Specified by:
setUri
in interfaceClientRequestContext
-
getMethod
- Specified by:
getMethod
in interfaceClientRequestContext
-
setMethod
- Specified by:
setMethod
in interfaceClientRequestContext
-
getClient
- Specified by:
getClient
in interfaceClientRequestContext
-
abortWith
- Specified by:
abortWith
in interfaceClientRequestContext
-
getAbortResponse
Get the request filter chain aborting response if set, ornull
otherwise.- Returns:
- request filter chain aborting response if set, or
null
otherwise.
-
getConfiguration
Description copied from class:OutboundMessageContext
The related client/server sideConfiguration
. Can benull
.- Specified by:
getConfiguration
in interfaceClientRequestContext
- Overrides:
getConfiguration
in classOutboundMessageContext
- Returns:
Configuration
the configuration
-
getRequestHeader
Get the values of an HTTP request header if the header exists on the current request. The returned value will be a read-only List if the specified header exists ornull
if it does not. This is a shortcut forgetRequestHeaders().get(name)
.- Specified by:
getRequestHeader
in interfaceHttpHeaders
- Parameters:
name
- the header name, case insensitive.- Returns:
- a read-only list of header values if the specified header exists, otherwise
null
. - Throws:
IllegalStateException
- if called outside the scope of a request.
-
getRequestHeaders
- Specified by:
getRequestHeaders
in interfaceHttpHeaders
-
getCookies
- Specified by:
getCookies
in interfaceClientRequestContext
- Specified by:
getCookies
in interfaceHttpHeaders
-
getWorkers
Get the message body workers associated with the request.- Returns:
- message body workers.
-
setWorkers
Set the message body workers associated with the request.- Parameters:
workers
- message body workers.
-
accept
Add new accepted types to the message headers.- Parameters:
types
- accepted types to be added.
-
accept
Add new accepted types to the message headers.- Parameters:
types
- accepted types to be added.
-
acceptLanguage
Add new accepted languages to the message headers.- Parameters:
locales
- accepted languages to be added.
-
acceptLanguage
Add new accepted languages to the message headers.- Parameters:
locales
- accepted languages to be added.
-
cookie
Add new cookie to the message headers.- Parameters:
cookie
- cookie to be added.
-
cacheControl
Add new cache control entry to the message headers.- Parameters:
cacheControl
- cache control entry to be added.
-
encoding
Set message encoding.- Parameters:
encoding
- message encoding to be set.
-
language
Set message language.- Parameters:
language
- message language to be set.
-
language
Set message language.- Parameters:
language
- message language to be set.
-
type
Set message content type.- Parameters:
type
- message content type to be set.
-
type
Set message content type.- Parameters:
type
- message content type to be set.
-
variant
Set message content variant (type, language and encoding).- Parameters:
variant
- message content content variant (type, language and encoding) to be set.
-
isAsynchronous
public boolean isAsynchronous()Returns true if the request is called asynchronously usingAsyncInvoker
- Returns:
- True if the request is asynchronous; false otherwise.
-
enableBuffering
public void enableBuffering()Enable a buffering of serialized entity. The buffering will be configured from runtime configuration associated with this request. The property determining the size of the buffer isCommonProperties.OUTBOUND_CONTENT_LENGTH_BUFFER
. The buffering functionality is by default disabled and could be enabled by calling this method. In this case this method must be called before first bytes are written to theentity stream
. -
writeEntity
Write (serialize) the entity set in this request into theentity stream
. The method usewriter interceptors
andmessage body writer
. This method modifies the state of this request and therefore it can be called only once per request life cycle otherwise IllegalStateException is thrown. Note thatOutboundMessageContext.setStreamProvider(org.glassfish.jersey.message.internal.OutboundMessageContext.StreamProvider)
and optionallyenableBuffering()
must be called before calling this method.- Throws:
IOException
- In the case of IO error.
-
getWriterInterceptors
Get writer interceptors of this request.- Returns:
- Writer interceptors in the interceptor execution order.
-
getReaderInterceptors
Get reader interceptors of this request.- Returns:
- Reader interceptors in the interceptor execution order.
-
getInjectionManager
public org.glassfish.jersey.internal.inject.InjectionManager getInjectionManager()Description copied from interface:org.glassfish.jersey.internal.inject.InjectionManagerSupplier
Get injection manager.- Specified by:
getInjectionManager
in interfaceorg.glassfish.jersey.internal.inject.InjectionManagerSupplier
- Returns:
- injection manager.
-
ignoreUserAgent
public boolean ignoreUserAgent()Indicates whether the User-Agent header should be omitted if not directly set to the map of headers.- Returns:
true
if the header should be omitted,false
otherwise.
-
ignoreUserAgent
public void ignoreUserAgent(boolean ignore) Indicates whether the User-Agent header should be omitted if not directly set to the map of headers.- Parameters:
ignore
-true
if the header should be omitted,false
otherwise.
-