Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-480

Content-Type header not sent by Undertow error-page filter

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor Minor
    • 1.2.9.Final, 1.3.0.Beta3
    • 1.3.0.Beta2
    • Core
    • None

      The Content-Type header is not sent by the error-page filter handler. This This does not appear to be configurable and is problematic when operating Wildfly behind an Apache instance where the Content-Type "text/plain" is added. This forces the content to be displayed as text even if it is HTML.

      Here is the undertow subsystem configuration:

              <subsystem xmlns="urn:jboss:domain:undertow:1.2">                                                                                                                                                      
                  <buffer-cache name="default"/>                                                                                                                                                                     
                  <server name="default-server">                                                                                                                                                                     
                      <http-listener name="default" socket-binding="http"/>                                                                                                                                          
                      <host name="default-host" alias="localhost">                                                                                                                                                   
                          <location name="/" handler="root-html" />                                                                                                                                                  
                          <location name="/images" handler="images"/>                                                                                                                                                
                          <filter-ref name="404-handler" predicate="true"/>                                                                                                                                          
                          <filter-ref name="fail-content-type" predicate="equals[%{RESPONSE_CODE}, 404]"/>                                                                                                           
                      </host>                                                                                                                                                                                        
                  </server>                                                                                                                                                                                          
                  <servlet-container name="default">                                                                                                                                                                 
                      <jsp-config/>                                                                                                                                                                                  
                      <websockets/>                                                                                                                                                                                  
                  </servlet-container>                                                                                                                                                                               
                  <handlers>                                                                                                                                                                                         
                      <file name="images" path="/var/www/images"/>                                                                                                                                                   
                      <file name="root-html" path="/var/www/html"/>                                                                                                                                                  
                  </handlers>                                                                                                                                                                                        
                  <filters>                                                                                                                                                                                          
                      <response-header name="fail-content-type" header-name="Content-Type" header-value="text/html"/>                                                                                              
                      <error-page name="404-handler" code="404" path="/var/www/error/404.html"/>                                                                                                                     
                  </filters>                                                                                                                                                                                         
              </subsystem> 
      

      You can see that we attempted to place a filter on the host to set the Content-type header if a 404 response code was received. However, after debugging the undertow subsystem, we found that the HttpServerExchange value in EqualsPredicate had a response code of 200 at the time the predicate was evluated.

      This behaves the same in Wildfly 8.2.0 and Wildfly 9.0.0 CR2.

              sdouglas1@redhat.com Stuart Douglas (Inactive)
              briehman_jira Brian Riehman (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: