@Override public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException { final InputStream originalInputStream = context.getInputStream(); context.setInputStream(new GZIPInputStream(originalInputStream)); return context.proceed(); }
@Override public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException { try { return context.proceed(); } catch (IOException e) { return "OK"; } }
/** * Extract and return service locator from {@link javax.ws.rs.ext.ReaderInterceptorContext * readerInterceptorContext}. The method can be used to inject custom types into a {@link * javax.ws.rs.ext.ReaderInterceptor}. * * @param readerInterceptorContext Reader interceptor context. * @return Service locator. * @throws java.lang.IllegalArgumentException when {@code readerInterceptorContext} is not a * default Jersey implementation provided by Jersey as argument in the {@link * javax.ws.rs.ext.ReaderInterceptor#aroundReadFrom(javax.ws.rs.ext.ReaderInterceptorContext)} * method. */ public static ServiceLocator getServiceLocator( ReaderInterceptorContext readerInterceptorContext) { if (!(readerInterceptorContext instanceof ServiceLocatorSupplier)) { throw new IllegalArgumentException( LocalizationMessages .ERROR_SERVICE_LOCATOR_PROVIDER_INSTANCE_FEATURE_READER_INTERCEPTOR_CONTEXT( readerInterceptorContext.getClass().getName())); } return ((ServiceLocatorSupplier) readerInterceptorContext).getServiceLocator(); }
@Override public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException { Object encoding = context.getHeaders().getFirst(HttpHeaders.CONTENT_ENCODING); if (encoding != null && encoding.toString().equalsIgnoreCase("gzip")) { InputStream old = context.getInputStream(); FinishableGZIPInputStream is = new FinishableGZIPInputStream( old, context instanceof ServerReaderInterceptorContext, getMaxSize()); context.setInputStream(is); try { return context.proceed(); } finally { // Don't finish() an InputStream - TODO this still will require a garbage collect to finish // the stream // see RESTEASY-554 for more details if (!context.getType().equals(InputStream.class)) is.finish(); context.setInputStream(old); } } else { return context.proceed(); } }