Java Code Examples for javax.ws.rs.client.ClientRequestContext#getEntityStream()
The following examples show how to use
javax.ws.rs.client.ClientRequestContext#getEntityStream() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoggingFilter.java From ameba with MIT License | 6 votes |
/** * {@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); } }
Example 2
Source File: MaskingLoggingFilter.java From gitlab4j-api with MIT License | 6 votes |
@Override public void filter(ClientRequestContext requestContext) throws IOException { if (!logger.isLoggable(level)) { return; } final long id = _id.incrementAndGet(); requestContext.setProperty(LOGGING_ID_PROPERTY, id); final StringBuilder sb = new StringBuilder(); printRequestLine(sb, "Sending client request", id, requestContext.getMethod(), requestContext.getUri()); printHeaders(sb, id, REQUEST_PREFIX, requestContext.getStringHeaders()); if (requestContext.hasEntity() && maxEntitySize > 0) { final OutputStream stream = new LoggingStream(sb, requestContext.getEntityStream()); requestContext.setEntityStream(stream); requestContext.setProperty(ENTITY_STREAM_PROPERTY, stream); } else { log(sb); } }
Example 3
Source File: LoggingFilter.java From docker-java with Apache License 2.0 | 6 votes |
@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); } }
Example 4
Source File: LoggingInterceptor.java From karate with MIT License | 5 votes |
@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); } HttpRequest actual = new HttpRequest(); context.setPrevRequest(actual); actual.startTimer(); }
Example 5
Source File: LocalRequest.java From logbook with MIT License | 4 votes |
@Override public State buffer(final ClientRequestContext context) { final TeeOutputStream stream = new TeeOutputStream(context.getEntityStream()); context.setEntityStream(stream); return new Buffering(stream); }