public class ClientRequest extends OutboundMessageContext implements javax.ws.rs.client.ClientRequestContext, javax.ws.rs.core.HttpHeaders, org.glassfish.jersey.internal.inject.InjectionManagerSupplier, PropertiesResolver
OutboundMessageContext.StreamProvider
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, LINK, LOCATION, RETRY_AFTER, SET_COOKIE, USER_AGENT, VARY, WWW_AUTHENTICATE
Modifier | Constructor and Description |
---|---|
|
ClientRequest(ClientRequest original)
Copy constructor.
|
protected |
ClientRequest(URI requestUri,
ClientConfig clientConfig,
PropertiesDelegate propertiesDelegate)
Create new Jersey client request context.
|
Modifier and Type | Method and Description |
---|---|
void |
abortWith(javax.ws.rs.core.Response response) |
void |
accept(javax.ws.rs.core.MediaType... types)
Add new accepted types to the message headers.
|
void |
accept(String... types)
Add new accepted types to the message headers.
|
void |
acceptLanguage(Locale... locales)
Add new accepted languages to the message headers.
|
void |
acceptLanguage(String... locales)
Add new accepted languages to the message headers.
|
void |
cacheControl(javax.ws.rs.core.CacheControl cacheControl)
Add new cache control entry to the message headers.
|
void |
cookie(javax.ws.rs.core.Cookie cookie)
Add new cookie to the message headers.
|
void |
enableBuffering()
Enable a buffering of serialized entity.
|
void |
encoding(String encoding)
Set message encoding.
|
javax.ws.rs.core.Response |
getAbortResponse()
Get the request filter chain aborting response if set, or
null otherwise. |
JerseyClient |
getClient() |
javax.ws.rs.core.Configuration |
getConfiguration()
The related client/server side
Configuration . |
Map<String,javax.ws.rs.core.Cookie> |
getCookies() |
org.glassfish.jersey.internal.inject.InjectionManager |
getInjectionManager()
Get injection manager.
|
String |
getMethod() |
Object |
getProperty(String name) |
Collection<String> |
getPropertyNames() |
Iterable<javax.ws.rs.ext.ReaderInterceptor> |
getReaderInterceptors()
Get reader interceptors of this request.
|
List<String> |
getRequestHeader(String name) |
javax.ws.rs.core.MultivaluedMap<String,String> |
getRequestHeaders() |
URI |
getUri() |
MessageBodyWorkers |
getWorkers()
Get the message body workers associated with the request.
|
Iterable<javax.ws.rs.ext.WriterInterceptor> |
getWriterInterceptors()
Get writer interceptors of this request.
|
boolean |
ignoreUserAgent()
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 |
isAsynchronous()
Returns true if the request is called asynchronously using
AsyncInvoker |
void |
language(Locale language)
Set message language.
|
void |
language(String language)
Set message language.
|
void |
removeProperty(String name) |
<T> T |
resolveProperty(String name,
Class<T> type)
Resolve a property value for the specified property
name . |
<T> T |
resolveProperty(String name,
T defaultValue)
Resolve a property value for the specified property
name . |
void |
setMethod(String method) |
void |
setProperty(String name,
Object object) |
void |
setUri(URI uri) |
void |
setWorkers(MessageBodyWorkers workers)
Set the message body workers associated with the request.
|
void |
type(javax.ws.rs.core.MediaType type)
Set message content type.
|
void |
type(String type)
Set message content type.
|
void |
variant(javax.ws.rs.core.Variant variant)
Set message content variant (type, language and encoding).
|
void |
writeEntity()
Write (serialize) the entity set in this request into the
entity stream . |
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAcceptableLanguages, getAcceptableMediaTypes, getDate, getEntity, getEntityAnnotations, getEntityClass, getEntityStream, getEntityType, getHeaders, getHeaderString, getLanguage, getMediaType, getStringHeaders, hasEntity, setEntity, setEntity, setEntityStream
getAcceptableLanguages, getAcceptableMediaTypes, getDate, getHeaderString, getLanguage, getLength, getMediaType
create
protected ClientRequest(URI requestUri, ClientConfig clientConfig, PropertiesDelegate propertiesDelegate)
requestUri
- request Uri.clientConfig
- request configuration.propertiesDelegate
- properties delegate.public ClientRequest(ClientRequest original)
original
- original instance.public <T> T resolveProperty(String name, Class<T> type)
PropertiesResolver
name
.
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 returns null
if no such property is
registered neither in the runtime nor in the request-specific property bag.
resolveProperty
in interface PropertiesResolver
T
- property Java type.name
- property name.type
- expected property class type.null
if no such property is registered.public <T> T resolveProperty(String name, T defaultValue)
PropertiesResolver
name
.
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 returns defaultValue
if no such property is
registered neither in the runtime nor in the request-specific property bag.
resolveProperty
in interface PropertiesResolver
T
- property Java type.name
- property name.defaultValue
- default value to return if the property is not registered.defaultValue
if no such property is registered.public Object getProperty(String name)
getProperty
in interface javax.ws.rs.client.ClientRequestContext
public Collection<String> getPropertyNames()
getPropertyNames
in interface javax.ws.rs.client.ClientRequestContext
public void setProperty(String name, Object object)
setProperty
in interface javax.ws.rs.client.ClientRequestContext
public void removeProperty(String name)
removeProperty
in interface javax.ws.rs.client.ClientRequestContext
public URI getUri()
getUri
in interface javax.ws.rs.client.ClientRequestContext
public void setUri(URI uri)
setUri
in interface javax.ws.rs.client.ClientRequestContext
public String getMethod()
getMethod
in interface javax.ws.rs.client.ClientRequestContext
public void setMethod(String method)
setMethod
in interface javax.ws.rs.client.ClientRequestContext
public JerseyClient getClient()
getClient
in interface javax.ws.rs.client.ClientRequestContext
public void abortWith(javax.ws.rs.core.Response response)
abortWith
in interface javax.ws.rs.client.ClientRequestContext
public javax.ws.rs.core.Response getAbortResponse()
null
otherwise.null
otherwise.public javax.ws.rs.core.Configuration getConfiguration()
OutboundMessageContext
Configuration
. Can be null
.getConfiguration
in interface javax.ws.rs.client.ClientRequestContext
getConfiguration
in class OutboundMessageContext
Configuration
the configurationpublic List<String> getRequestHeader(String name)
getRequestHeader
in interface javax.ws.rs.core.HttpHeaders
public javax.ws.rs.core.MultivaluedMap<String,String> getRequestHeaders()
getRequestHeaders
in interface javax.ws.rs.core.HttpHeaders
public Map<String,javax.ws.rs.core.Cookie> getCookies()
getCookies
in interface javax.ws.rs.client.ClientRequestContext
getCookies
in interface javax.ws.rs.core.HttpHeaders
public MessageBodyWorkers getWorkers()
public void setWorkers(MessageBodyWorkers workers)
workers
- message body workers.public void accept(javax.ws.rs.core.MediaType... types)
types
- accepted types to be added.public void accept(String... types)
types
- accepted types to be added.public void acceptLanguage(Locale... locales)
locales
- accepted languages to be added.public void acceptLanguage(String... locales)
locales
- accepted languages to be added.public void cookie(javax.ws.rs.core.Cookie cookie)
cookie
- cookie to be added.public void cacheControl(javax.ws.rs.core.CacheControl cacheControl)
cacheControl
- cache control entry to be added.public void encoding(String encoding)
encoding
- message encoding to be set.public void language(String language)
language
- message language to be set.public void language(Locale language)
language
- message language to be set.public void type(javax.ws.rs.core.MediaType type)
type
- message content type to be set.public void type(String type)
type
- message content type to be set.public void variant(javax.ws.rs.core.Variant variant)
variant
- message content content variant (type, language and encoding)
to be set.public boolean isAsynchronous()
AsyncInvoker
public void enableBuffering()
CommonProperties.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 the entity stream
.public void writeEntity() throws IOException
entity stream
. The method
use writer interceptors
and message 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 that OutboundMessageContext.setStreamProvider(org.glassfish.jersey.message.internal.OutboundMessageContext.StreamProvider)
and optionally enableBuffering()
must be called before calling this method.IOException
- In the case of IO error.public Iterable<javax.ws.rs.ext.WriterInterceptor> getWriterInterceptors()
public Iterable<javax.ws.rs.ext.ReaderInterceptor> getReaderInterceptors()
public org.glassfish.jersey.internal.inject.InjectionManager getInjectionManager()
org.glassfish.jersey.internal.inject.InjectionManagerSupplier
getInjectionManager
in interface org.glassfish.jersey.internal.inject.InjectionManagerSupplier
public boolean ignoreUserAgent()
true
if the header should be omitted, false
otherwise.public void ignoreUserAgent(boolean ignore)
ignore
- true
if the header should be omitted, false
otherwise.Copyright © 2007-2021, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.