Skip to content

Instantly share code, notes, and snippets.

@voronianski
Last active January 19, 2021 01:08
Show Gist options
  • Save voronianski/791ef517c5392d7ce5fb to your computer and use it in GitHub Desktop.
Save voronianski/791ef517c5392d7ce5fb to your computer and use it in GitHub Desktop.
What happens if you serve content with a different length than the Content-Length header?

@jakearchibald done a bit of research around this:

###Loading a page with Content-Length < actual content length

  • Chrome: Truncated content - no indication of error
  • Firefox: Truncated content - no indication of error
  • Safari: Truncated content - no indication of error
  • IE: Truncated content - no indication of error

###Loading a page with Content-Length > actual content length

  • Chrome: Rendered received content, spinner until timeout, ERR_CONTENT_LENGTH_MISMATCH & ERR_CACHE_MISS in console
  • Firefox: No in-progress render, spinner until timeout, rendered received content, no console errors
  • Safari: No in-progress render, spinner until timeout, no final render, "Failed to load resource: The network connection was lost." in console
  • IE: No in-progress render, spinner until timeout, rendered received content, no console errors

###Loading a page with Content-Length > actual content length ending in abrupt server termination

  • Chrome: Received content rendered, ERR_CONTENT_LENGTH_MISMATCH in console
  • Firefox: Received content rendered, no errors
  • Safari: No content render "Safari can’t open the page “‎localhost:3000/app-name/” because the server unexpectedly dropped the connection."
  • IE: Received content rendered, no errors

###Loading a page with no Content-Length, chunked encoding & abrupt server termination

  • Chrome: Received content rendered, ERR_INCOMPLETE_CHUNKED_ENCODING in console
  • Firefox: Received content rendered, no errors
  • Safari: Received content rendered, no errors
  • IE: Received content rendered, no errors

###XHR a page with Content-Length < actual content length

  • Chrome: load event, truncated content
  • Firefox: load event, truncated content
  • Safari: load event, truncated content
  • IE: load event, truncated content

###XHR a page with Content-Length > actual content length

  • Chrome: waits until timeout, error event, ERR_CONTENT_LENGTH_MISMATCH in console
  • Firefox: waits until timeout, load event, received content delivered
  • Safari: waits until timeout, error event, "Failed to load resource: The network connection was lost." in console
  • IE: waits until timeout, load event, received content delivered

###XHR a page with Content-Length > actual content length ending in abrupt server termination

  • Chrome: error event, ERR_CONTENT_LENGTH_MISMATCH in console
  • Firefox: load event, received content delivered
  • Safari: error event, "Failed to load resource: The network connection was lost." in console
  • IE: load event, received content delivered

###XHR a page with no Content-Length, chunked encoding & abrupt server termination

  • Chrome: error event, ERR_INCOMPLETE_CHUNKED_ENCODING in console
  • Firefox: load event, received content delivered
  • Safari: load event, received content delivered
  • IE: load event, received content delivered
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment