Java Code Examples for javax.ws.rs.ext.ReaderInterceptorContext#setInputStream()
The following examples show how to use
javax.ws.rs.ext.ReaderInterceptorContext#setInputStream() .
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 dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@Override public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException { byte[] buffer = IOUtils.toByteArray(context.getInputStream()); logger.info("The contents of request body is: \n" + new String(buffer, "UTF-8") + "\n"); context.setInputStream(new ByteArrayInputStream(buffer)); return context.proceed(); }
Example 2
Source File: AbstractFilterInterceptorTest.java From servicetalk with Apache License 2.0 | 5 votes |
@Override public Object aroundReadFrom(final ReaderInterceptorContext readerInterceptorCtx) throws IOException { final InputStream old = readerInterceptorCtx.getInputStream(); readerInterceptorCtx.setInputStream(new UpperCaseInputStream(old)); try { return readerInterceptorCtx.proceed(); } finally { readerInterceptorCtx.setInputStream(old); } }
Example 3
Source File: DecompressInterceptor.java From hugegraph with Apache License 2.0 | 5 votes |
@Override public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException { // NOTE: Currently we just support GZIP String encoding = context.getHeaders().getFirst("Content-Encoding"); if (!GZIP.equalsIgnoreCase(encoding)) { return context.proceed(); } context.setInputStream(new GZIPInputStream(context.getInputStream())); return context.proceed(); }
Example 4
Source File: GZipInterceptor.java From Alpine with Apache License 2.0 | 5 votes |
@Override public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException { final List<String> header = context.getHeaders().get(HttpHeaders.CONTENT_ENCODING); if (header != null && header.contains("gzip")) { // DO NOT CLOSE STREAMS final InputStream contentInputSteam = context.getInputStream(); final GZIPInputStream gzipInputStream = new GZIPInputStream(contentInputSteam); context.setInputStream(gzipInputStream); } return context.proceed(); }
Example 5
Source File: ConditionalBase64ReadInterceptor.java From jrestless with Apache License 2.0 | 5 votes |
@Override public final Object aroundReadFrom(ReaderInterceptorContext context) throws IOException { if (isBase64(context)) { context.setInputStream(Base64.getDecoder().wrap(context.getInputStream())); } return context.proceed(); }
Example 6
Source File: TestHttpTarget.java From datacollector with Apache License 2.0 | 5 votes |
@Override public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException { if (context.getHeaders().containsKey("Content-Encoding") && context.getHeaders().get("Content-Encoding").contains("snappy")) { InputStream originalInputStream = context.getInputStream(); context.setInputStream(new SnappyFramedInputStream(originalInputStream, true)); } return context.proceed(); }
Example 7
Source File: SnappyReaderInterceptor.java From datacollector with Apache License 2.0 | 5 votes |
@Override public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException { if (context.getHeaders().containsKey(CONTENT_ENCODING) && context.getHeaders().get(CONTENT_ENCODING).contains(SNAPPY)) { InputStream originalInputStream = context.getInputStream(); context.setInputStream(new SnappyFramedInputStream(originalInputStream, true)); } return context.proceed(); }
Example 8
Source File: GZIPReaderInterceptor.java From divide with Apache License 2.0 | 5 votes |
@Override public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException { final InputStream originalInputStream = context.getInputStream(); context.setInputStream(new GZIPInputStream(originalInputStream)); return context.proceed(); }
Example 9
Source File: FormReaderInterceptor.java From cxf with Apache License 2.0 | 5 votes |
@Override public Object aroundReadFrom(ReaderInterceptorContext ctx) throws IOException, WebApplicationException { BufferedReader br = new BufferedReader(new InputStreamReader(ctx.getInputStream())); String line; while ((line = br.readLine()) != null) { LOG.info("readLine: " + line); } ByteArrayInputStream bais = new ByteArrayInputStream("value=MODIFIED".getBytes()); LOG.info("set value=MODIFIED"); ctx.setInputStream(bais); return ctx.proceed(); }
Example 10
Source File: RequestServerReaderInterceptor.java From tutorials with MIT License | 5 votes |
@Override public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException { LOG.info("Request reader interceptor in the server side"); InputStream is = context.getInputStream(); String body = new BufferedReader(new InputStreamReader(is)).lines() .collect(Collectors.joining("\n")); context.setInputStream(new ByteArrayInputStream((body + " message added in server reader interceptor").getBytes())); return context.proceed(); }
Example 11
Source File: GZIPReaderInterceptor.java From wings with Apache License 2.0 | 5 votes |
@Override public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException { List<String> ce = context.getHeaders().get("content-encoding"); if (ce != null && ce.contains("gzip")) { final InputStream originalInputStream = context.getInputStream(); context.setInputStream(new GZIPInputStream(originalInputStream)); } return context.proceed(); }
Example 12
Source File: LoggingFilter.java From dubbox with Apache License 2.0 | 4 votes |
public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException { byte[] buffer = IOUtils.toByteArray(context.getInputStream()); logger.info("The contents of request body is: \n" + new String(buffer, "UTF-8") + "\n"); context.setInputStream(new ByteArrayInputStream(buffer)); return context.proceed(); }
Example 13
Source File: LoggingFilter.java From dubbox-hystrix with Apache License 2.0 | 4 votes |
public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException { byte[] buffer = IOUtils.toByteArray(context.getInputStream()); logger.info("The contents of request body is: \n" + new String(buffer, "UTF-8") + "\n"); context.setInputStream(new ByteArrayInputStream(buffer)); return context.proceed(); }
Example 14
Source File: LoggingFilter.java From dubbox with Apache License 2.0 | 4 votes |
public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException { byte[] buffer = IOUtils.toByteArray(context.getInputStream()); logger.info("The contents of request body is: \n" + new String(buffer, "UTF-8") + "\n"); context.setInputStream(new ByteArrayInputStream(buffer)); return context.proceed(); }
Example 15
Source File: LoggingFilter.java From dubbox with Apache License 2.0 | 4 votes |
public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException { byte[] buffer = IOUtils.toByteArray(context.getInputStream()); logger.info("The contents of request body is: \n" + new String(buffer, "UTF-8") + "\n"); context.setInputStream(new ByteArrayInputStream(buffer)); return context.proceed(); }