Class ClientRequest
- All Implemented Interfaces:
ClientRequestContext,HttpHeaders,HttpHeaders,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 class org.glassfish.jersey.message.internal.MessageHeaderMethods
runtimeDelegateDecoratorFields 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_AUTHENTICATEFields 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
ConstructorsModifierConstructorDescriptionprotectedClientRequest(URI requestUri, ClientConfig clientConfig, PropertiesDelegate propertiesDelegate) Create new Jersey client request context.ClientRequest(ClientRequest original) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidAdd new accepted types to the message headers.voidAdd new accepted types to the message headers.voidacceptLanguage(String... locales) Add new accepted languages to the message headers.voidacceptLanguage(Locale... locales) Add new accepted languages to the message headers.voidcacheControl(CacheControl cacheControl) Add new cache control entry to the message headers.voidcancel(boolean mayInterruptIfRunning) Cancels thisClientRequest.voidAdd new cookie to the message headers.voidEnable a buffering of serialized entity.voidSet message encoding.Get the request filter chain aborting response if set, ornullotherwise.The related client/server sideConfiguration.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.booleanhasProperty(String name) booleanIndicates whether the User-Agent header should be omitted if not directly set to the map of headers.voidignoreUserAgent(boolean ignore) Indicates whether the User-Agent header should be omitted if not directly set to the map of headers.booleanReturns true if the request is called asynchronously usingAsyncInvokerbooleanReturnstrueif thisClientRequestwas cancelled before it completed normally.voidSet message language.voidSet message language.voidremoveProperty(String name) <T> TresolveProperty(String name, Class<T> type) Resolve a property value for the specified propertyname.<T> TresolveProperty(String name, T defaultValue) Resolve a property value for the specified propertyname.voidvoidsetProperty(String name, Object object) voidvoidsetWorkers(MessageBodyWorkers workers) Set the message body workers associated with the request.voidSet message content type.voidSet message content type.voidSet message content variant (type, language and encoding).voidWrite (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, getEntity, getEntityAnnotations, getEntityClass, getEntityStream, getEntityType, getHeaders, getHeaderString, getHeaderValueExceptionContext, getLinks, getMediaType, getStringHeaders, hasEntity, isCommitted, replaceHeaders, setEntity, setEntity, setEntity, setEntity, setEntityAnnotations, setEntityStream, setEntityType, setMediaType, setStreamProviderMethods inherited from class org.glassfish.jersey.message.internal.MessageHeaderMethods
containsHeaderString, containsHeaderString, exception, getAllowedMethods, getDate, getEntityTag, getLanguage, getLastModified, getLength, getLengthLong, getLink, getLinkBuilder, getLocation, getRequestCookies, getResponseCookies, hasLink, singleHeader, singleHeaderMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jakarta.ws.rs.client.ClientRequestContext
getAcceptableLanguages, getAcceptableMediaTypes, getDate, getEntity, getEntityAnnotations, getEntityClass, getEntityStream, getEntityType, getHeaders, getHeaderString, getLanguage, getMediaType, getStringHeaders, hasEntity, setEntity, setEntity, setEntityStreamMethods 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:PropertiesResolverResolve 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 configurationthis request belongs to. If there is a value defined in the runtime configuration, it is returned, otherwise the method returnsnullif no such property is registered neither in the runtime nor in the request-specific property bag.- Specified by:
resolvePropertyin interfacePropertiesResolver- Type Parameters:
T- property Java type.- Parameters:
name- property name.type- expected property class type.- Returns:
- resolved property value or
nullif no such property is registered.
-
resolveProperty
Description copied from interface:PropertiesResolverResolve 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 configurationthis request belongs to. If there is a value defined in the runtime configuration, it is returned, otherwise the method returnsdefaultValueif no such property is registered neither in the runtime nor in the request-specific property bag.- Specified by:
resolvePropertyin 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
defaultValueif no such property is registered.
-
hasProperty
- Specified by:
hasPropertyin interfaceClientRequestContext
-
getProperty
- Specified by:
getPropertyin interfaceClientRequestContext
-
getPropertyNames
- Specified by:
getPropertyNamesin interfaceClientRequestContext
-
setProperty
- Specified by:
setPropertyin interfaceClientRequestContext
-
removeProperty
- Specified by:
removePropertyin interfaceClientRequestContext
-
getUri
- Specified by:
getUriin interfaceClientRequestContext
-
setUri
- Specified by:
setUriin interfaceClientRequestContext
-
getMethod
- Specified by:
getMethodin interfaceClientRequestContext
-
setMethod
- Specified by:
setMethodin interfaceClientRequestContext
-
getClient
- Specified by:
getClientin interfaceClientRequestContext
-
abortWith
- Specified by:
abortWithin interfaceClientRequestContext
-
getAbortResponse
Get the request filter chain aborting response if set, ornullotherwise.- Returns:
- request filter chain aborting response if set, or
nullotherwise.
-
getConfiguration
Description copied from class:OutboundMessageContextThe related client/server sideConfiguration. Can benull.- Specified by:
getConfigurationin interfaceClientRequestContext- Overrides:
getConfigurationin classOutboundMessageContext- Returns:
Configurationthe 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 ornullif it does not. This is a shortcut forgetRequestHeaders().get(name).- Specified by:
getRequestHeaderin 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:
getRequestHeadersin interfaceHttpHeaders
-
getCookies
- Specified by:
getCookiesin interfaceClientRequestContext- Specified by:
getCookiesin 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 interceptorsandmessage 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
Description copied from interface:InjectionManagerSupplierGet injection manager.- Specified by:
getInjectionManagerin interfaceInjectionManagerSupplier- 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:
trueif the header should be omitted,falseotherwise.
-
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-trueif the header should be omitted,falseotherwise.
-
cancel
public void cancel(boolean mayInterruptIfRunning) Cancels thisClientRequest. May result inCancellationExceptionlater in this request processing if thisClientRequestis backed by aFutureprovided toJerseyInvocation.Builder.setCancellable(Future).- Parameters:
mayInterruptIfRunning- may have no effect ortrueif the thread executing this task should be interrupted (if the thread is known to the implementation); otherwise, in-progress tasks are allowed to complete
-
isCancelled
public boolean isCancelled()Returnstrueif thisClientRequestwas cancelled before it completed normally.- Returns:
trueif thisClientRequestwas cancelled before it completed normally
-