@VisibleForTesting static void prepareHeaders( Metadata headers, DecompressorRegistry decompressorRegistry, Compressor compressor, boolean fullStreamDecompression) { headers.discardAll(MESSAGE_ENCODING_KEY); if (compressor != Codec.Identity.NONE) { headers.put(MESSAGE_ENCODING_KEY, compressor.getMessageEncoding()); } headers.discardAll(MESSAGE_ACCEPT_ENCODING_KEY); byte[] advertisedEncodings = InternalDecompressorRegistry.getRawAdvertisedMessageEncodings(decompressorRegistry); if (advertisedEncodings.length != 0) { headers.put(MESSAGE_ACCEPT_ENCODING_KEY, advertisedEncodings); } headers.discardAll(CONTENT_ENCODING_KEY); headers.discardAll(CONTENT_ACCEPT_ENCODING_KEY); if (fullStreamDecompression) { headers.put(CONTENT_ACCEPT_ENCODING_KEY, FULL_STREAM_DECOMPRESSION_ENCODINGS); } }
@Override public void start(Listener<O> responseListener, Metadata unused) { requireNonNull(responseListener, "responseListener"); final Compressor compressor; if (callOptions.getCompressor() != null) { compressor = compressorRegistry.lookupCompressor(callOptions.getCompressor()); if (compressor == null) { responseListener.onClose( Status.INTERNAL.withDescription( "Unable to find compressor by name " + callOptions.getCompressor()), EMPTY_METADATA); return; } } else { compressor = Identity.NONE; } messageFramer.setCompressor(compressor); prepareHeaders(req.headers(), compressor); listener = responseListener; final HttpResponse res; try { res = httpClient.execute(ctx, req); } catch (Exception e) { close(Status.fromThrowable(e)); return; } res.subscribe(responseReader, ctx.eventLoop(), true); }
private void prepareHeaders(HttpHeaders headers, Compressor compressor) { if (compressor != Identity.NONE) { headers.set(GrpcHeaderNames.GRPC_ENCODING, compressor.getMessageEncoding()); } String advertisedEncodings = String.join(",", decompressorRegistry.getAdvertisedMessageEncodings()); if (!advertisedEncodings.isEmpty()) { headers.add(GrpcHeaderNames.GRPC_ACCEPT_ENCODING, advertisedEncodings); } headers.add(GrpcHeaderNames.GRPC_TIMEOUT, TimeoutHeaderUtil.toHeaderValue( TimeUnit.MILLISECONDS.toNanos(ctx.responseTimeoutMillis()))); }
@Override public void setCompressor(final Compressor compressor) { checkNotNull(compressor, "compressor"); delayOrExecute(new Runnable() { @Override public void run() { realStream.setCompressor(compressor); } }); }
@Override public final void setCompressor(final Compressor compressor) { class CompressorEntry implements BufferEntry { @Override public void runWith(Substream substream) { substream.stream.setCompressor(compressor); } } delayOrExecute(new CompressorEntry()); }
public void setCompressor(Compressor compressor) { this.compressor = compressor; }
@Override public void setCompressor(Compressor compressor) {}
/** Set the compressor used for compression. */ Framer setCompressor(Compressor compressor);
@Override public Framer setCompressor(Compressor compressor) { return this; }
@Override public MessageFramer setCompressor(Compressor compressor) { this.compressor = checkNotNull(compressor, "Can't pass an empty compressor"); return this; }
@Override public final void setCompressor(Compressor compressor) { framer().setCompressor(checkNotNull(compressor, "compressor")); }
/** * Sets the compressor on the framer. * * @param compressor the compressor to use */ void setCompressor(Compressor compressor);