javax.ws.rs.ext.ReaderInterceptorContext#getInputStream ( )源码实例Demo

下面列出了javax.ws.rs.ext.ReaderInterceptorContext#getInputStream ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@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);
    }
}
 
源代码2 项目: Alpine   文件: GZipInterceptor.java
@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();
}
 
源代码3 项目: datacollector   文件: TestHttpTarget.java
@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();
}
 
源代码4 项目: datacollector   文件: SnappyReaderInterceptor.java
@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();
}
 
源代码5 项目: divide   文件: GZIPReaderInterceptor.java
@Override
public Object aroundReadFrom(ReaderInterceptorContext context)
        throws IOException, WebApplicationException {
    final InputStream originalInputStream = context.getInputStream();
    context.setInputStream(new GZIPInputStream(originalInputStream));
    return context.proceed();
}
 
源代码6 项目: cxf   文件: FormReaderInterceptor.java
@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();
}
 
源代码7 项目: cxf   文件: JAXRS20ClientServerBookTest.java
@Override
public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException,
    WebApplicationException {
    if (context.getInputStream() != null) {
        context.getHeaders().add("ClientReaderInterceptor", "clientRead");
    }
    return context.proceed();
}
 
@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();
}
 
源代码9 项目: wings   文件: GZIPReaderInterceptor.java
@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();
}