MediaType mediaType = request.getMediaType();
MediaType mediaType = request.getMediaType(); URI lUri = request.getUri(); } else { invocation = builder.build(method, Entity.entity(request.getEntity(), request.getMediaType()));
MediaType mediaType = request.getMediaType(); URI lUri = request.getUri(); } else { invocation = builder.build(method, Entity.entity(request.getEntity(), request.getMediaType()));
MediaType mediaType = request.getMediaType(); URI lUri = request.getUri(); } else { invocation = builder.build(method, Entity.entity(request.getEntity(), request.getMediaType()));
@Override public void filter(final ClientRequestContext context) throws IOException { if (!logger.isLoggable(level)) { return; } 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 (context.hasEntity() && printEntity(verbosity, 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); } }
@Override public void filter(final ClientRequestContext context) throws IOException { if (!logger.isLoggable(level)) { return; } 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 (context.hasEntity() && printEntity(verbosity, 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); } }
if (ds.getAlgorithm() == Algorithm.MD5_SESS) { ha1 = md5(md5(credentials.getUsername(), ds.getRealm(), new String(credentials.getPassword(), MessageUtils.getCharset(requestContext.getMediaType())))); } else { ha1 = md5(credentials.getUsername(), ds.getRealm(), new String(credentials.getPassword(), MessageUtils.getCharset(requestContext.getMediaType())));
if (ds.getAlgorithm() == Algorithm.MD5_SESS) { ha1 = md5(md5(credentials.getUsername(), ds.getRealm(), new String(credentials.getPassword(), MessageUtils.getCharset(requestContext.getMediaType())))); } else { ha1 = md5(credentials.getUsername(), ds.getRealm(), new String(credentials.getPassword(), MessageUtils.getCharset(requestContext.getMediaType())));
if (ds.getAlgorithm() == Algorithm.MD5_SESS) { ha1 = md5(md5(credentials.getUsername(), ds.getRealm(), new String(credentials.getPassword(), MessageUtils.getCharset(requestContext.getMediaType())))); } else { ha1 = md5(credentials.getUsername(), ds.getRealm(), new String(credentials.getPassword(), MessageUtils.getCharset(requestContext.getMediaType())));
@Override public String getContentType() { return context.getMediaType() == null ? null : context.getMediaType().toString(); }
@Override public String getContentType() { return context.getMediaType() == null ? null : context.getMediaType().toString(); }
@Override public Charset getCharset() { return HttpMessages.getCharset(context.getMediaType()); }
@Override public InputStream getContent() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); final Object entity = clientRequestContext.getEntity(); if (entity == null) { return null; } else { MessageBodyWriter messageBodyWriter = workers.getMessageBodyWriter(entity.getClass(), entity.getClass(), new Annotation[]{}, clientRequestContext.getMediaType()); try { // use the MBW to serialize entity into baos messageBodyWriter.writeTo(entity, entity.getClass(), entity.getClass(), new Annotation[] {}, clientRequestContext.getMediaType(), new MultivaluedHashMap<String, Object>(), baos); } catch (IOException e) { throw new RuntimeException( "Error while serializing entity.", e); } return new ByteArrayInputStream(baos.toByteArray()); } }
@Override public void filter(ClientRequestContext ctx) throws IOException { MediaType contentType = ctx.getMediaType(); if (contentType != null && "multipart".equals(contentType.getType())) { List<Object> parts = getAttachmentParts(ctx.getEntity()); ctx.setEntity(parts); } } }
@Override public void filter(final ClientRequestContext context) throws IOException { if (!logger.isLoggable(level)) { return; } 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 (context.hasEntity() && printEntity(verbosity, 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); } }
@Override public void filter(final ClientRequestContext context) throws IOException { if (!logger.isLoggable(level)) { return; } 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 (context.hasEntity() && printEntity(verbosity, 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); } }
final Builder builder = resourceTarget.request(request.getMediaType()); invocation = builder.build(method, Entity.entity(request.getEntity(), request.getMediaType()));
@Override public void filter(final ClientRequestContext context) throws IOException { String uriPath = context.getUri().getPath(); if (!logger.isTraceEnabled() || jerseyFiltering.excludeForUri(uriPath)) { return; } long id = _id.incrementAndGet(); context.setProperty(LOGGING_ID_PROPERTY, id); context.setProperty(Constants.REST_TIMING, System.currentTimeMillis()); StringBuilder b = new StringBuilder(); URI uri = context.getUri(); recordOutgoing(context, "sending"); printRequestLine(b, "Sending client request", id, context.getMethod(), uri); printPrefixedHeaders(b, id, REQUEST_PREFIX, context.getStringHeaders()); if (context.hasEntity() && printEntity(verbosity, context.getMediaType()) && !jerseyFiltering.excludePayloadForUri(uriPath)) { 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); } }
/** * {@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); } }
@Override public void filter(ClientRequestContext rc) throws IOException { String method = rc.getMethod(); String expectedMethod = null; if (rc.getAcceptableMediaTypes().contains(MediaType.valueOf("text/mistypedxml")) && rc.getHeaders().getFirst("THEMETHOD") != null) { expectedMethod = MediaType.TEXT_XML_TYPE.equals(rc.getMediaType()) ? "DELETE" : "GET"; rc.setUri(URI.create("http://localhost:" + PORT + "/bookstore/books2")); rc.setMethod(rc.getHeaders().getFirst("THEMETHOD").toString()); if ("GET".equals(expectedMethod)) { rc.getHeaders().putSingle("Content-Type", "text/xml"); } } else { expectedMethod = "POST"; } if (!expectedMethod.equals(method)) { throw new RuntimeException(); } if ("GET".equals(expectedMethod)) { rc.setEntity(new Book("book", 560L)); } else { rc.setEntity(new Book("book", ((Book)rc.getEntity()).getId() + 5)); } }