Skip to content

Commit

Permalink
sanity check accept-encoding header in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdanfox committed Mar 27, 2020
1 parent 8a24c6f commit 9766414
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.palantir.dialogue.example.SampleServiceAsync;
import com.palantir.dialogue.example.SampleServiceBlocking;
import com.palantir.dialogue.hc4.ApacheHttpClientChannels;
import com.palantir.logsafe.Preconditions;
import io.undertow.Undertow;
import io.undertow.server.HttpHandler;
import io.undertow.server.handlers.BlockingHandler;
Expand Down Expand Up @@ -122,6 +123,10 @@ public void stream_3_gigabytes() throws IOException {
private void setBinaryGzipResponse(String stringToCompress) {
undertowHandler = exchange -> {
exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "application/octet-stream");
Preconditions.checkArgument(exchange.getRequestHeaders().contains(Headers.ACCEPT_ENCODING));
Preconditions.checkArgument(exchange.getRequestHeaders()
.getFirst(Headers.ACCEPT_ENCODING)
.contains("gzip"));
exchange.getResponseHeaders().put(Headers.CONTENT_ENCODING, "gzip");
exchange.getOutputStream().write(gzipCompress(stringToCompress));
};
Expand Down

0 comments on commit 9766414

Please sign in to comment.