示例#1
0
        public static Utf8Bytes AcceptWebSocketKey(Utf8Bytes key)
        {
            var concat = key + Utf8Bytes.From("258EAFA5-E914-47DA-95CA-C5AB0DC85B11");

            using (var sha1 = SHA1.Create())
            {
                var bs = sha1.ComputeHash(concat.Bytes.Array, concat.Bytes.Offset, concat.Bytes.Count);
                return(Utf8Bytes.From(Convert.ToBase64String(bs)));
            }
        }
示例#2
0
        void InternalError(Exception ex)
        {
            Logging.Error(String.Format("{0} - {1}", ID, ex));
            using (var s = new NetworkStream(Socket, false))
            {
                Http10StatusLine.InternalError.WriteTo(s); s.CRLF();
                s.CRLF();

                Utf8Bytes.From(ex.ToString()).WriteTo(s);
            }
            Dispose();
        }
示例#3
0
 public FileMounter(String mountPoint, Func <Byte[]> content)
 {
     m_mountPoint = Utf8Bytes.From(mountPoint);
     m_content    = content;
 }
示例#4
0
 public FolderMounter(string mountPoint, string path, PathFilter pathFilter)
 {
     m_mountPoint = Utf8Bytes.From(mountPoint);
     m_path       = path;
     m_filter     = pathFilter;
 }
        public void WebSocketTest()
        {
            var accepted = HttpSession.AcceptWebSocketKey(Utf8Bytes.From("dGhlIHNhbXBsZSBub25jZQ=="));

            Assert.AreEqual(Utf8Bytes.From("s3pPLMBiTxaQ9kYGzzhZRbK+xOo="), accepted);
        }