Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -207,19 +207,25 @@ public string GetHeaderValue(ReadOnlySpan<byte> headerValue, Encoding? valueEnco
break;

case 10:
switch (contentTypeValue[0])
switch (contentTypeValue[6])
{
case (byte)'t': candidate = "text/plain"; break; // [t]ext/plain
case (byte)'i': candidate = "image/jpeg"; break; // [i]mage/jpeg
case (byte)'l': candidate = "text/plain"; break; // text/p[l]ain
case (byte)'j': candidate = "image/jpeg"; break; // image/[j]peg
case (byte)'w': candidate = "image/webp"; break; // image/[w]ebp
}
break;

case 13:
candidate = "image/svg+xml"; // image/svg+xml
break;

case 15:
switch (contentTypeValue[12])
{
case (byte)'p': candidate = "application/pdf"; break; // application/[p]df
case (byte)'x': candidate = "application/xml"; break; // application/[x]ml
case (byte)'z': candidate = "application/zip"; break; // application/[z]ip
case (byte)'i': candidate = "text/javascript"; break; // text/javascr[i]pt
}
break;

Expand All @@ -231,6 +237,10 @@ public string GetHeaderValue(ReadOnlySpan<byte> headerValue, Encoding? valueEnco
}
break;

case 17:
candidate = "text/event-stream"; // text/event-stream
break;

case 19:
candidate = "multipart/form-data"; // multipart/form-data
break;
Expand All @@ -239,17 +249,47 @@ public string GetHeaderValue(ReadOnlySpan<byte> headerValue, Encoding? valueEnco
candidate = "application/javascript"; // application/javascript
break;

case 23:
switch (contentTypeValue[18])
{
case (byte)'u': candidate = "text/html;charset=utf-8"; break; // text/html;charset=[u]tf-8
case (byte)'U': candidate = "text/html;charset=UTF-8"; break; // text/html;charset=[U]TF-8
}
break;

case 24:
switch (contentTypeValue[19])
switch (contentTypeValue[10] ^ contentTypeValue[19])
{
case (byte)'t': candidate = "application/octet-stream"; break; // application/octet-s[t]ream
case (byte)'u': candidate = "text/html; charset=utf-8"; break; // text/html; charset=[u]tf-8
case (byte)'U': candidate = "text/html; charset=UTF-8"; break; // text/html; charset=[U]TF-8
case 'n' ^ 't': candidate = "application/octet-stream"; break; // applicatio[n]/octet-s[t]ream
case ' ' ^ 'u': candidate = "text/html; charset=utf-8"; break; // text/html;[ ]charset=[u]tf-8
case ' ' ^ 'U': candidate = "text/html; charset=UTF-8"; break; // text/html;[ ]charset=[U]TF-8
case ';' ^ 'u': candidate = "text/plain;charset=utf-8"; break; // text/plain[;]charset=[u]tf-8
case ';' ^ 'U': candidate = "text/plain;charset=UTF-8"; break; // text/plain[;]charset=[U]TF-8
}
break;

case 25:
candidate = "text/plain; charset=utf-8"; // text/plain; charset=utf-8
switch (contentTypeValue[20])
{
case (byte)'u': candidate = "text/plain; charset=utf-8"; break; // text/plain; charset=[u]tf-8
case (byte)'U': candidate = "text/plain; charset=UTF-8"; break; // text/plain; charset=[U]TF-8
}
break;

case 29:
switch (contentTypeValue[19])
{
case (byte)'I': candidate = "text/html; charset=ISO-8859-1"; break; // text/html; charset=[I]SO-8859-1
case (byte)'i': candidate = "text/html; charset=iso-8859-1"; break; // text/html; charset=[i]so-8859-1
}
break;

case 30:
switch (contentTypeValue[25])
{
case (byte)'u': candidate = "text/javascript; charset=utf-8"; break; // text/javascript; charset=[u]tf-8
case (byte)'U': candidate = "text/javascript; charset=UTF-8"; break; // text/javascript; charset=[U]TF-8
}
break;

case 31:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ namespace System.Net.Http.Headers
{
internal sealed partial class KnownHeader
{
public KnownHeader(string name, int? http2StaticTableIndex = null, int? http3StaticTableIndex = null) :
this(name, HttpHeaderType.Custom, parser: null, knownValues: null, http2StaticTableIndex, http3StaticTableIndex)
{
Debug.Assert(!string.IsNullOrEmpty(name));
Debug.Assert(name[0] == ':' || HttpRuleParser.IsToken(name));
}
public KnownHeader(string name, string[]? knownValues = null, int? http2StaticTableIndex = null, int? http3StaticTableIndex = null)
: this(name, HttpHeaderType.Custom, parser: null, knownValues, http2StaticTableIndex, http3StaticTableIndex)
{ }

public KnownHeader(string name, HttpHeaderType headerType, HttpHeaderParser? parser, string[]? knownValues = null, int? http2StaticTableIndex = null, int? http3StaticTableIndex = null)
{
Expand Down
Loading
Loading