Skip to content
  • Jon Dufresne's avatar
    c2e756a9
    Remove body content from redirect responses · c2e756a9
    Jon Dufresne authored
    Modern browsers don't render this HTML so it goes unused in practice.
    The delivered bytes are therefore a small waste (although very small)
    and unnecessary and could be optimized away.
    
    Additionally, the HTML fails validation. Using the W3C v.Nu, we see the
    following errors:
    
        Warning: Consider adding a lang attribute to the html start tag to declare the language of this document.
    
        Error: Start tag seen without seeing a doctype first. Expected <!DOCTYPE html>.
    
        Error: Element head is missing a required instance of child element title.
    
    These errors may surface in site-wide compliance tests (either internal
    tests or external contractual tests). Avoid the false positives by
    removing the HTML.
    
    While these warnings and errors could be resolved, it would be simpler
    on future maintenance to remove the body altogether (especially as it
    isn't rendered by the browser). As the same string is copied around a
    few places, this removes multiple touch points to resolve the current
    validation errors as well as new ones.
    
    Many other frameworks and web servers don't include an HTML body on
    redirect, so there isn't a reason for Rails to do so. By removing the
    custom Rails HTML, there are fewing "fingerprints" that a malicious bot
    could use to identify the backend technologies.
    
    Application controllers that wish to add a response body after calling
    redirect_to can continue to do so.
    c2e756a9
    Remove body content from redirect responses
    Jon Dufresne authored
    Modern browsers don't render this HTML so it goes unused in practice.
    The delivered bytes are therefore a small waste (although very small)
    and unnecessary and could be optimized away.
    
    Additionally, the HTML fails validation. Using the W3C v.Nu, we see the
    following errors:
    
        Warning: Consider adding a lang attribute to the html start tag to declare the language of this document.
    
        Error: Start tag seen without seeing a doctype first. Expected <!DOCTYPE html>.
    
        Error: Element head is missing a required instance of child element title.
    
    These errors may surface in site-wide compliance tests (either internal
    tests or external contractual tests). Avoid the false positives by
    removing the HTML.
    
    While these warnings and errors could be resolved, it would be simpler
    on future maintenance to remove the body altogether (especially as it
    isn't rendered by the browser). As the same string is copied around a
    few places, this removes multiple touch points to resolve the current
    validation errors as well as new ones.
    
    Many other frameworks and web servers don't include an HTML body on
    redirect, so there isn't a reason for Rails to do so. By removing the
    custom Rails HTML, there are fewing "fingerprints" that a malicious bot
    could use to identify the backend technologies.
    
    Application controllers that wish to add a response body after calling
    redirect_to can continue to do so.
Loading