@Override public void filter(ClientRequestContext context) throws IOException { if (context.hasEntity() && context.getHeaders().getFirst(HttpHeaders.CONTENT_ENCODING) == null && this.forceEncoding) { context.getHeaders().add(HttpHeaders.CONTENT_ENCODING, "gzip"); } }
@Override public void filter(ClientRequestContext request) throws IOException { if (getSupportedEncodings().isEmpty()) { return; } request.getHeaders().addAll(HttpHeaders.ACCEPT_ENCODING, getSupportedEncodings()); String useEncoding = (String) request.getConfiguration().getProperty(ClientProperties.USE_ENCODING); if (useEncoding != null) { if (!getSupportedEncodings().contains(useEncoding)) { Logger.getLogger(getClass().getName()).warning(LocalizationMessages.USE_ENCODING_IGNORED( ClientProperties.USE_ENCODING, useEncoding, getSupportedEncodings())); } else { if (request.hasEntity()) { // don't add Content-Encoding header for requests with no entity if (request.getHeaders().getFirst(HttpHeaders.CONTENT_ENCODING) == null) { request.getHeaders().putSingle(HttpHeaders.CONTENT_ENCODING, useEncoding); } } } } }
@Override public void filter(ClientRequestContext request) throws IOException { if (getSupportedEncodings().isEmpty()) { return; } request.getHeaders().addAll(HttpHeaders.ACCEPT_ENCODING, getSupportedEncodings()); String useEncoding = (String) request.getConfiguration().getProperty(ClientProperties.USE_ENCODING); if (useEncoding != null) { if (!getSupportedEncodings().contains(useEncoding)) { Logger.getLogger(getClass().getName()).warning(LocalizationMessages.USE_ENCODING_IGNORED( ClientProperties.USE_ENCODING, useEncoding, getSupportedEncodings())); } else { if (request.hasEntity()) { // don't add Content-Encoding header for requests with no entity if (request.getHeaders().getFirst(HttpHeaders.CONTENT_ENCODING) == null) { request.getHeaders().putSingle(HttpHeaders.CONTENT_ENCODING, useEncoding); } } } } }
@Override public void filter(ClientRequestContext request) throws IOException { if (getSupportedEncodings().isEmpty()) { return; } request.getHeaders().addAll(HttpHeaders.ACCEPT_ENCODING, getSupportedEncodings()); String useEncoding = (String) request.getConfiguration().getProperty(ClientProperties.USE_ENCODING); if (useEncoding != null) { if (!getSupportedEncodings().contains(useEncoding)) { Logger.getLogger(getClass().getName()).warning(LocalizationMessages.USE_ENCODING_IGNORED( ClientProperties.USE_ENCODING, useEncoding, getSupportedEncodings())); } else { if (request.hasEntity()) { // don't add Content-Encoding header for requests with no entity if (request.getHeaders().getFirst(HttpHeaders.CONTENT_ENCODING) == null) { request.getHeaders().putSingle(HttpHeaders.CONTENT_ENCODING, useEncoding); } } } } }
@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 { 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); } }
@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(ClientRequestContext requestContext) throws IOException { Tracer.SpanBuilder spanBuilder = GlobalTracer.get() .buildSpan(LocalizationMessages.OPENTRACING_SPAN_PREFIX_CLIENT() + requestContext.getMethod()) .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT) .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT) .withTag(Tags.HTTP_URL.getKey(), requestContext.getUri().toASCIIString()) .withTag(Tags.HTTP_METHOD.getKey(), requestContext.getMethod()) .withTag(LocalizationMessages.OPENTRACING_TAG_HAS_REQUEST_ENTITY(), requestContext.hasEntity()) .withTag(LocalizationMessages.OPENTRACING_TAG_ACCEPTABLE_MEDIA_TYPES(), requestContext.getAcceptableMediaTypes() .stream() .map(MediaType::toString) .collect(Collectors.joining(", "))) .withTag(LocalizationMessages.OPENTRACING_TAG_REQUEST_HEADERS(), OpenTracingUtils.headersAsString(requestContext.getHeaders())); // if pre-stored "span" property is found, propagate the stored context final Object property = requestContext.getProperty(OpenTracingFeature.SPAN_CONTEXT_PROPERTY); if (property != null && property instanceof SpanContext) { spanBuilder = spanBuilder.asChildOf((SpanContext) property); } Span span = spanBuilder.startManual(); requestContext.setProperty(OpenTracingFeature.SPAN_CONTEXT_PROPERTY, span); Map<String, String> addedHeaders = new HashMap<>(); GlobalTracer.get().inject(span.context(), Format.Builtin.HTTP_HEADERS, new TextMapInjectAdapter(addedHeaders)); addedHeaders.forEach((key, value) -> requestContext.getHeaders().add(key, value)); } }
@Override public void filter(ClientRequestContext requestContext) throws IOException { if (requestContext.hasEntity()) { // let WriterInterceptor handle this return; } MultivaluedMap<String, Object> headers = requestContext.getHeaders(); List<DKIMSignature> list = getHeaders(headers); for (DKIMSignature dosetaSignature : list) { KeyRepository repository = (KeyRepository) requestContext.getProperty(KeyRepository.class.getName()); try { sign(repository, headers, null, dosetaSignature); } catch (Exception e) { throw new ProcessingException(e); } } }
@Override public void filter(ClientRequestContext context) throws IOException { if (context.hasEntity() && context.getHeaders().getFirst(HttpHeaders.CONTENT_ENCODING) == null && this.forceEncoding) { context.getHeaders().add(HttpHeaders.CONTENT_ENCODING, "gzip"); } }
@Override public void filter(final ClientRequestContext context) throws IOException { final RawHttpRequest request = new LocalRequest(context); if (context.hasEntity()) { context.setProperty(REQUEST, request); } else { logRequest(context::setProperty, request); } }
@Override public void filter(ClientRequestContext context) throws IOException { StringBuilder request = new StringBuilder(); request.append("HTTP Request\n"); request.append(context.getMethod() + " " + context.getUri() + "\n"); appendHeaders(request, context.getStringHeaders()); if (context.hasEntity()) { OutputStream stream = new RequestLoggingStream(request, context.getEntityStream()); context.setEntityStream(stream); context.setProperty(REQUEST_LOGGING_STREAM, stream); } else { log.debug(request.toString()); } }
@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); } }
@Override public void filter(ClientRequestContext context) throws IOException { String opName = (String)JAXRSUtils.getCurrentMessage().getExchange().get("org.apache.cxf.resource.operation.name"); assertFalse(opName.endsWith("?a=b")); context.getHeaders().putSingle("Simple", "simple"); if (context.hasEntity()) { context.getHeaders().putSingle("Content-Type", MediaType.APPLICATION_XML_TYPE); } } }
@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()) { 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 { 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()) { 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); } }
@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()) { 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); } }
/** * {@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); } }