本文整理匯總了Java中javax.ws.rs.client.ClientRequestContext.hasEntity方法的典型用法代碼示例。如果您正苦於以下問題:Java ClientRequestContext.hasEntity方法的具體用法?Java ClientRequestContext.hasEntity怎麽用?Java ClientRequestContext.hasEntity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.ws.rs.client.ClientRequestContext
的用法示例。
在下文中一共展示了ClientRequestContext.hasEntity方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: filter
import javax.ws.rs.client.ClientRequestContext; //導入方法依賴的package包/類
@Override
public void filter(ClientRequestContext clientRequestContext) throws IOException {
String method = clientRequestContext.getMethod();
URI uri = clientRequestContext.getUri();
MultivaluedMap<String, Object> headers = clientRequestContext.getHeaders();
System.out.printf("Sending %s to: %s\n", method, uri);
System.out.printf("Headers:\n");
for(String key : headers.keySet()) {
System.out.printf(" %s: %s\n", key, headers.getFirst(key));
}
if(clientRequestContext.hasEntity()) {
final OutputStream stream = new LoggingStream(clientRequestContext.getEntityStream());
clientRequestContext.setEntityStream(stream);
clientRequestContext.setProperty("client.LoggingStream", stream);
}
}
示例2: filter
import javax.ws.rs.client.ClientRequestContext; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public void filter(final ClientRequestContext context) throws IOException {
final long id = _id.incrementAndGet();
context.setProperty(LOGGING_ID_PROPERTY, id);
final StringBuilder b = new StringBuilder();
printRequestLine(b, "Sending client request", id, context.getMethod(), context.getUri());
printPrefixedHeaders(b, id, REQUEST_PREFIX, context.getStringHeaders());
if (printEntity && context.hasEntity() && isSupportPrintType(context.getMediaType())) {
final OutputStream stream = new LoggingStream(b, context.getEntityStream());
context.setEntityStream(stream);
context.setProperty(ENTITY_LOGGER_PROPERTY, stream);
// not calling log(b) here - it will be called by the interceptor
} else {
log(b);
}
}
示例3: filter
import javax.ws.rs.client.ClientRequestContext; //導入方法依賴的package包/類
@Override
public void filter(final ClientRequestContext context) throws IOException {
final long id = aid.incrementAndGet();
final StringBuilder b = new StringBuilder();
printRequestLine(b, "Sending client request", id, context.getMethod(), context.getUri());
printPrefixedHeaders(b, id, REQUEST_PREFIX, context.getStringHeaders());
if (printEntity && context.hasEntity()) {
final OutputStream stream = new LoggingStream(b, context.getEntityStream());
context.setEntityStream(stream);
context.setProperty(ENTITY_LOGGER_PROPERTY, stream);
// not calling log(b) here - it will be called by the interceptor
} else {
log(b);
}
}
示例4: filter
import javax.ws.rs.client.ClientRequestContext; //導入方法依賴的package包/類
@Override
public void filter( ClientRequestContext context ) throws IOException {
if (debugLevel == RESTDebugLevel.NONE || debugLevel == RESTDebugLevel.TARGET_URI) {
return;
}
MultivaluedMap<String, Object> reqHeaders = context.getHeaders();
StringBuilder requestMessage = new StringBuilder();
requestMessage.append("Sending the following request: \n");
if ( (debugLevel & RESTDebugLevel.HEADERS) == RESTDebugLevel.HEADERS) {
requestMessage.append(context.getMethod() + " " + context.getUri() + " \n");
for (Entry<String, List<Object>> reqHeaderEntry : reqHeaders.entrySet()) {
requestMessage.append(reqHeaderEntry.getKey() + ": "
+ Arrays.toString(reqHeaderEntry.getValue().toArray()) + " \n");
}
}
if ( (debugLevel & RESTDebugLevel.BODY) == RESTDebugLevel.BODY && context.hasEntity()) {
//log request body
Object entity = context.getEntity();
if (entity instanceof Form) {
requestMessage.append("Body: " + ((Form) entity).asMap());
} else {
requestMessage.append("Body: " + entity.toString());
}
}
log.info(requestMessage);
}
示例5: filter
import javax.ws.rs.client.ClientRequestContext; //導入方法依賴的package包/類
@Override
public void filter(ClientRequestContext request) throws IOException {
if (request.hasEntity() && isPrintable(request.getMediaType())) {
LoggingFilterOutputStream out = new LoggingFilterOutputStream(request.getEntityStream());
request.setEntityStream(out);
request.setProperty(LoggingFilterOutputStream.KEY, out);
}
}
示例6: filter
import javax.ws.rs.client.ClientRequestContext; //導入方法依賴的package包/類
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
if (logger.isDebugEnabled()) {
logUrl(requestContext);
}
if (logger.isTraceEnabled()) {
logHeaders(requestContext);
if (requestContext.hasEntity()) {
wrapEntityStreamWithLogger(requestContext);
}
}
}
示例7: filter
import javax.ws.rs.client.ClientRequestContext; //導入方法依賴的package包/類
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
if (requestContext.hasEntity()) {
assertEquals(ConverterNetworkProtocol.COMPRESSION_TYPE_GZIP, requestContext.getHeaderString(HttpHeaders.CONTENT_ENCODING));
}
List<String> acceptEncodings = requestContext.getStringHeaders().get(HttpHeaders.ACCEPT_ENCODING);
assertEquals(2, acceptEncodings.size());
assertTrue(acceptEncodings.contains(ConverterNetworkProtocol.COMPRESSION_TYPE_GZIP));
assertTrue(acceptEncodings.contains(ConverterNetworkProtocol.COMPRESSION_TYPE_XGZIP));
}