From ba62bf08179d4f06c1a514c891f4345ab3c86b44 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 Sep 2018 15:22:59 +0900 Subject: [PATCH] [Modify] Add it --- websocket-sharp/Net/HttpUtility.cs | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 44ce18b1..154e7f77 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -464,6 +464,40 @@ namespace WebSocketSharp.Net c == '_'; } + private static void urlEncode (byte b, Stream output) + { + if (b > 31 && b < 127) { + if (b == 32) { + output.WriteByte ((byte) '+'); + return; + } + + if (isNumeric (b)) { + output.WriteByte (b); + return; + } + + if (isAlphabet (b)) { + output.WriteByte (b); + return; + } + + if (isUnreserved (b)) { + output.WriteByte (b); + return; + } + } + + output.WriteByte ((byte) '%'); + + var i = (int) b; + var idx = i >> 4; + output.WriteByte ((byte) _hexChars[idx]); + + idx = i & 0x0F; + output.WriteByte ((byte) _hexChars[idx]); + } + private static void urlEncode (char c, Stream result, bool unicode) { if (c > 255) {