Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-23796

[QA](7.4.z) UNDERTOW-2116 - java.lang.AssertionError: Content-Encoding header should be defined

XMLWordPrintable

      Using a gzip filter-ref in undertow config ....

      <subsystem xmlns="urn:jboss:domain:undertow:12.0" default-server="default-server" default-virtual-host="default-host" default-servlet-container="default" default-security-domain="other" statistics-enabled="${wildfly.undertow.statistics-enabled:${wildfly.statistics-enabled:false}}">
                  <buffer-cache name="default"/>
                  <server name="default-server">
                      <http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true"/>
                      <https-listener name="https" socket-binding="https" security-realm="ApplicationRealm" enable-http2="true"/>
                      <host name="default-host" alias="localhost">
                          <location name="/" handler="welcome-content"/>
                          <access-log/>
                          <filter-ref name="gzip-filter"/>
                          <http-invoker security-realm="ApplicationRealm"/>
                      </host>
                  </server>
                  <servlet-container name="default">
                      <jsp-config/>
                      <websockets/>
                  </servlet-container>
                  <handlers>
                      <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
                  </handlers>
                  <filters>
                      <gzip name="gzip-filter"/>
                  </filters>
              </subsystem>
      

       

      the following test fails with .... 

      java.lang.AssertionError: Content-Encoding header should be defined

       

       

       @Test
          public void gzipDefaultAsOnDemandBehaviourTest(@ArquillianResource URL url) throws  {
              String targetUrl = url.toExternalForm() + "index.html";
      
              HttpHead standardRequest = new HttpHead(targetUrl);
      
              HttpHead gzipExplicitRequest = new HttpHead(targetUrl);
              gzipExplicitRequest.addHeader(Headers.ACCEPT_ENCODING_STRING, "gzip");
      
              HttpHead gzipDeflateExplicitRequest = new HttpHead(targetUrl);
              gzipDeflateExplicitRequest.addHeader(Headers.ACCEPT_ENCODING_STRING, "gzip");
              gzipDeflateExplicitRequest.addHeader(Headers.ACCEPT_ENCODING_STRING, "deflate");
      
      String compressionType="gzip";
      
             try (CloseableHttpClient httpClient = HttpClientBuilder.create().disableContentCompression().build()) {
                  CloseableHttpResponse response = httpClient.execute(gzipDeflateExplicitRequest);
                  Assert.assertEquals(HttpURLConnection.HTTP_OK, response.getStatusLine().getStatusCode());
                  Header contentEncodingHeader = response.getFirstHeader(Headers.CONTENT_ENCODING_STRING);
         
                  Assert.assertNotNull("Content-Encoding header should be defined", contentEncodingHeader);
                 Assert.assertEquals("Content-Encoding header should be defined with value '" + compressionType.toLowerCase() + "'",
                          compressionType.toLowerCase(), contentEncodingHeader.getValue().toLowerCase());
              }
          }
      

              rhn-support-rmartinc Ricardo Martin Camarero
              psotirop@redhat.com Panagiotis Sotiropoulos (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: