Test Cases for HTTP Content-Type handling

Please send feedback to julian.reschke@gmx.de.

Related Reading

Test Result Summary

Colors -- Red: Failure, Green: Pass, Yellow: Warning, Grey: Not Supported

Score -- Passes: 2 points, Warning: 1 point, in percent of possible points (this should be updated to count optional features differently)

Test CaseFirefox 79Google Chrome 84Safari 13.1.2
Summary84% passes, 5% failures, 11% warnings, 0% unsupported, 0% to-do
Score: 89
89% passes, 0% failures, 11% warnings, 0% unsupported, 0% to-do
Score: 95
68% passes, 11% failures, 21% warnings, 0% unsupported, 0% to-do
Score: 79
Charset Defaultingtextplainnodefaultutf8warn (defaults to ISO-8859 as per RFC 2616) warn (defaults to ISO-8859 as per RFC 2616) warn (defaults to ISO-8859 as per RFC 2616)
textplainnodefaultiso88591warn (defaults to ISO-8859 as per RFC 2616) warn (defaults to ISO-8859 as per RFC 2616) warn (defaults to ISO-8859 as per RFC 2616)
textxmlnodefaultutf8passpasspass
textxmlnodefaultutf8nodeclpasspassfail (apparently defaults to ISO-8859-1 (see WebKit Bug 215764))
textxmlnodefaultiso88591passpasspass
textxmlnodefaultiso88591nodeclfail (attempts to parse with no charset information and fails because ISO-8859-1 is not an autodetected encoding in XML) passpass
Charset Parsingtextplainutf8passpasspass
textplainutf8wspass (charset parameter ignored) pass (charset parameter ignored) warn (either not ignored, or encoding sniffed)
textplainutf8qspasspasspass
textplainutf8qsapasspasswarn (either not ignored, or encoding sniffed)
textplainutf8qsescapedpasspassfail
textplainutf8extparampasspasspass
textplainutf8extparamqspasspasspass
textplainutf8extparamqs1passpasspass
textplainutf8extparamsqpasspasspass
Multiple Field Valuesmultixmltextonelinepass (detects text/xml) pass (detects text/xml) pass (detects text/plain (!!! - see WebKit Bug 215604))
multixmltexttwolinepass (detects text/xml) pass (detects text/xml) pass (detects text/xml)
multitextxmlonelinepass (detects text/plain) pass (detects text/plain) pass (detects text/xml (!!! - see WebKit Bug 215604))
multitextxmltwolinepass (detects text/plain) pass (detects text/plain) pass (detects text/plain)

Test Cases

Charset Defaulting

Various tests checking charset defaulting.

textplainnodefaultutf8 [TEST] [R]

Content-Type: text/plain

Payload, encoded in UTF-8:

Umlaute: 漩周 Euro: €
Test Results
Firefoxwarn (defaults to ISO-8859 as per RFC 2616)
Chromewarn (defaults to ISO-8859 as per RFC 2616)
Safariwarn (defaults to ISO-8859 as per RFC 2616)

text/plain, no charset given, body encoded in UTF-8

Default according to RFC 6657 is US-ASCII

Result for this UA:

textplainnodefaultiso88591 [TEST] [R]

Content-Type: text/plain

Payload, encoded in ISO-8859-1:

Umlaute: 漩周
Test Results
Firefoxwarn (defaults to ISO-8859 as per RFC 2616)
Chromewarn (defaults to ISO-8859 as per RFC 2616)
Safariwarn (defaults to ISO-8859 as per RFC 2616)

text/plain, no charset given, body using ISO-8859-1

Default according to RFC 6657 is US-ASCII

Result for this UA:

textxmlnodefaultutf8 [TEST] [R]

Content-Type: text/xml

Payload, encoded in UTF-8:

<?xml version="1.0" encoding="UTF-8"?>
<foo>Umlaute: 漩周 Euro: €</foo>
Test Results
Firefoxpass
Chromepass
Safaripass

text/xml, no charset given, body using UTF-8 (and declaring so)

Result for this UA:

textxmlnodefaultutf8nodecl [TEST] [R]

Content-Type: text/xml

Payload, encoded in UTF-8:

<foo>Umlaute: 漩周 Euro: €</foo>
Test Results
Firefoxpass
Chromepass
Safarifail (apparently defaults to ISO-8859-1 (see WebKit Bug 215764))

text/xml, no charset given, body using UTF-8 (and not declaring so)

Result for this UA:

textxmlnodefaultiso88591 [TEST] [R]

Content-Type: text/xml

Payload, encoded in ISO-8859-1:

<?xml version="1.0" encoding="ISO-8859-1"?>
<foo>Umlaute: 漩周</foo>
Test Results
Firefoxpass
Chromepass
Safaripass

text/xml, no charset given, body using ISO-8859-1 (and declaring so)

Result for this UA:

textxmlnodefaultiso88591nodecl [TEST] [R]

Content-Type: text/xml

Payload, encoded in ISO-8859-1:

<foo>Umlaute: 漩周</foo>
Test Results
Firefoxfail (attempts to parse with no charset information and fails because ISO-8859-1 is not an autodetected encoding in XML)
Chromepass
Safaripass

text/xml, no charset given, body using ISO-8859-1 (and declaring so)

Result for this UA:

Charset Parsing

Various tests checking charset parsing.

textplainutf8 [TEST] [R]

Content-Type: text/plain; charset=UTF-8

Payload, encoded in UTF-8:

Umlaute: 漩周 Euro: €
Test Results
Firefoxpass
Chromepass
Safaripass

text/plain, charset UTF-8, body using UTF-8

Result for this UA:

textplainutf8ws [TEST] [R]

Content-Type: text/plain; charset = UTF-8

Payload, encoded in UTF-8:

Umlaute: 漩周 Euro: €
Test Results
Firefoxpass (charset parameter ignored)
Chromepass (charset parameter ignored)
Safariwarn (either not ignored, or encoding sniffed)

text/plain, charset UTF-8, whitespace around "=", body using UTF-8

Result for this UA:

textplainutf8qs [TEST] [R]

Content-Type: text/plain; charset="UTF-8"

Payload, encoded in UTF-8:

Umlaute: 漩周 Euro: €
Test Results
Firefoxpass
Chromepass
Safaripass

text/plain, charset UTF-8 (quoted), body using UTF-8

Result for this UA:

textplainutf8qsa [TEST] [R]

Content-Type: text/plain; charset='UTF-8'

Payload, encoded in UTF-8:

Umlaute: 漩周 Euro: €
Test Results
Firefoxpass
Chromepass
Safariwarn (either not ignored, or encoding sniffed)

text/plain, charset in single quotes, which according to the specs does not match "UTF-8" (it's "'UTF-8'"), body using UTF-8

Result for this UA:

textplainutf8qsescaped [TEST] [R]

Content-Type: text/plain; charset="UTF-\8"

Payload, encoded in UTF-8:

Umlaute: 漩周 Euro: €
Test Results
Firefoxpass
Chromepass
Safarifail

text/plain, charset UTF-8 (quoted, using quoted-string escapes), body using UTF-8

Result for this UA:

textplainutf8extparam [TEST] [R]

Content-Type: text/plain; foo=bar; charset="UTF-8"

Payload, encoded in UTF-8:

Umlaute: 漩周 Euro: €
Test Results
Firefoxpass
Chromepass
Safaripass

text/plain, charset UTF-8 (quoted), with extension parameter before charset parameter, body using UTF-8

Result for this UA:

textplainutf8extparamqs [TEST] [R]

Content-Type: text/plain; foo="\""; charset="UTF-8"

Payload, encoded in UTF-8:

Umlaute: 漩周 Euro: €
Test Results
Firefoxpass
Chromepass
Safaripass

text/plain, charset UTF-8 (quoted), with extension parameter using quoted-string syntax before charset parameter, body using UTF-8

Result for this UA:

textplainutf8extparamqs1 [TEST] [R]

Content-Type: text/plain; foo="; charset=\"UTF-8\""

Payload, encoded in UTF-8:

Umlaute: 漩周 Euro: €
Test Results
Firefoxpass
Chromepass
Safaripass

text/plain, extension parameter using quoted-string, with charset param appearing as text content in the extension parameter's value, body using UTF-8

Result for this UA:

textplainutf8extparamsq [TEST] [R]

Content-Type: text/plain; foo='; charset="UTF-8"

Payload, encoded in UTF-8:

Umlaute: 漩周 Euro: €
Test Results
Firefoxpass
Chromepass
Safaripass

text/plain, charset UTF-8 (quoted), with extension parameter using a single quote in the token format before charset parameter, body using UTF-8

Result for this UA:

Multiple Field Values

Multiple field values, either comma-separated or in multiple instances. All invalid.

multixmltextoneline [TEST] [R]

Content-Type: text/plain, text/xml

Payload, encoded in US-ASCII:

<?xml version="1.0"?>
<foo>bar</foo>
Test Results
Firefoxpass (detects text/xml)
Chromepass (detects text/xml)
Safaripass (detects text/plain (!!! - see WebKit Bug 215604))

multiple field values in one line: plain, then xml, body is XML

Result for this UA:

multixmltexttwoline [TEST] [R]

Content-Type: text/plain
Content-Type: text/xml

Payload, encoded in US-ASCII:

<?xml version="1.0"?>
<foo>bar</foo>
Test Results
Firefoxpass (detects text/xml)
Chromepass (detects text/xml)
Safaripass (detects text/xml)

multiple field values in two lines: plain, then xml, body is XML

Result for this UA:

multitextxmloneline [TEST] [R]

Content-Type: text/xml, text/plain

Payload, encoded in US-ASCII:

<?xml version="1.0"?>
<foo>bar</foo>
Test Results
Firefoxpass (detects text/plain)
Chromepass (detects text/plain)
Safaripass (detects text/xml (!!! - see WebKit Bug 215604))

multiple field values in one line: xml, then plain, body is XML

Result for this UA:

multitextxmltwoline [TEST] [R]

Content-Type: text/xml
Content-Type: text/plain

Payload, encoded in US-ASCII:

<?xml version="1.0"?>
<foo>bar</foo>
Test Results
Firefoxpass (detects text/plain)
Chromepass (detects text/plain)
Safaripass (detects text/plain)

multiple field values in two lines: xml, then plain, body is XML

Result for this UA:

Test Case Generation

Both this document and the indiviual test "scripts" are generated from one single XML source (httpcontenttype.xml), using an XSLT2 transformation (httpcontenttype.xslt).

To generate the files, an XSLT2 processor such as Saxon 10 is needed. Copy both files into an empty directory, then run:

saxon10 httpcontenttype.xml httpcontenttype.xslt > index.html

Note that this will also generate a set of "asis" files that contain the actual test cases. These can be served using the Apache httpd mod_asis module.