diff options
| author | stefan <stefan@hegedues.at> | 2018-09-12 19:26:21 +0200 |
|---|---|---|
| committer | stefan <stefan@hegedues.at> | 2018-09-12 19:26:21 +0200 |
| commit | 48facb797ed912e4ea6b04b17d1ff190ac2daac4 (patch) | |
| tree | 8dae77a31670a888d733484cb17dd4077d5444e8 /SocketHttpListener/Net/WebHeaderEncoding.cs | |
| parent | c32d8656382a0eacb301692e0084377fc433ae9b (diff) | |
Update to 3.5.2 and .net core 2.1
Diffstat (limited to 'SocketHttpListener/Net/WebHeaderEncoding.cs')
| -rw-r--r-- | SocketHttpListener/Net/WebHeaderEncoding.cs | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/SocketHttpListener/Net/WebHeaderEncoding.cs b/SocketHttpListener/Net/WebHeaderEncoding.cs index 4a080179e..7290bfc63 100644 --- a/SocketHttpListener/Net/WebHeaderEncoding.cs +++ b/SocketHttpListener/Net/WebHeaderEncoding.cs @@ -83,48 +83,5 @@ namespace SocketHttpListener.Net } return bytes; } - - // The normal client header parser just casts bytes to chars (see GetString). - // Check if those bytes were actually utf-8 instead of ASCII. - // If not, just return the input value. - internal static string DecodeUtf8FromString(string input) - { - if (string.IsNullOrWhiteSpace(input)) - { - return input; - } - - bool possibleUtf8 = false; - for (int i = 0; i < input.Length; i++) - { - if (input[i] > (char)255) - { - return input; // This couldn't have come from the wire, someone assigned it directly. - } - else if (input[i] > (char)127) - { - possibleUtf8 = true; - break; - } - } - if (possibleUtf8) - { - byte[] rawBytes = new byte[input.Length]; - for (int i = 0; i < input.Length; i++) - { - if (input[i] > (char)255) - { - return input; // This couldn't have come from the wire, someone assigned it directly. - } - rawBytes[i] = (byte)input[i]; - } - try - { - return s_utf8Decoder.GetString(rawBytes); - } - catch (ArgumentException) { } // Not actually Utf-8 - } - return input; - } } } |
