HttpEncoders { @Nullable static HttpEncodingType getWrapperForRequest(HttpRequest request) { final String acceptEncoding = request.headers().get(HttpHeaderNames.ACCEPT_ENCODING); if (acceptEncoding == null) { return null; } return determineEncoding(acceptEncoding); } private  HttpEncoders();   }
@Test public void noAcceptEncoding() { when(request.headers()).thenReturn(RequestHeaders.of(HttpMethod.GET, "/")); assertThat(HttpEncoders.getWrapperForRequest(request)).isNull(); }
@Test public void acceptEncodingGzip() { when(request.headers()).thenReturn(RequestHeaders.of(HttpMethod.GET, "/", HttpHeaderNames.ACCEPT_ENCODING, "gzip")); assertThat(HttpEncoders.getWrapperForRequest(request)).isEqualTo(HttpEncodingType.GZIP); }
@Test public void acceptEncodingDeflate() { when(request.headers()).thenReturn(RequestHeaders.of(HttpMethod.GET, "/", HttpHeaderNames.ACCEPT_ENCODING, "deflate")); assertThat(HttpEncoders.getWrapperForRequest(request)).isEqualTo(HttpEncodingType.DEFLATE); }
@Test public void acceptEncodingBoth() { when(request.headers()).thenReturn(RequestHeaders.of(HttpMethod.GET, "/", HttpHeaderNames.ACCEPT_ENCODING, "gzip, deflate")); assertThat(HttpEncoders.getWrapperForRequest(request)).isEqualTo(HttpEncodingType.GZIP); }
@Test public void acceptEncodingUnknown() { when(request.headers()).thenReturn(RequestHeaders.of(HttpMethod.GET, "/", HttpHeaderNames.ACCEPT_ENCODING, "piedpiper")); assertThat(HttpEncoders.getWrapperForRequest(request)).isNull(); }