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

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

源代码1 项目: dubbo-2.6.5   文件: LoggingFilter.java
@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();
}
 
@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);
    }
}
 
源代码3 项目: hugegraph   文件: DecompressInterceptor.java
@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();
}
 
源代码4 项目: 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();
}
 
@Override
public final Object aroundReadFrom(ReaderInterceptorContext context) throws IOException {
	if (isBase64(context)) {
		context.setInputStream(Base64.getDecoder().wrap(context.getInputStream()));
	}
	return context.proceed();
}
 
源代码6 项目: 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();
}
 
源代码7 项目: 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();
}
 
源代码8 项目: 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();
}
 
源代码9 项目: 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();
}
 
源代码10 项目: tutorials   文件: RequestServerReaderInterceptor.java
@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();
}
 
源代码11 项目: 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();
}
 
源代码12 项目: dubbox   文件: LoggingFilter.java
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();
}
 
源代码13 项目: dubbox-hystrix   文件: LoggingFilter.java
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();
}
 
源代码14 项目: dubbox   文件: LoggingFilter.java
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();
}
 
源代码15 项目: dubbox   文件: LoggingFilter.java
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();
}