예제 #1
0
        public static RequestHandshake Parse(string[] request)
        {
            var requestLine = request[0].Split(' ');

            if (requestLine.Length != 3)
            {
                var msg = "Invalid HTTP Request-Line: " + request[0];
                throw new ArgumentException(msg, "request");
            }

            var headers = new WebHeaderCollection();

            for (int i = 1; i < request.Length; i++)
            {
                headers.Add(request[i]);
            }

            return(new RequestHandshake
            {
                Headers = headers,
                HttpMethod = requestLine[0],
                RequestUri = Ext.ToUri(requestLine[1]),
                ProtocolVersion = new Version(requestLine[2].Substring(5))
            });
        }
예제 #2
0
        public RequestHandshake(string uriString)
        {
            HttpMethod = "GET";
            RequestUri = Ext.ToUri(uriString);

            AddHeader("Upgrade", "websocket");
            AddHeader("Connection", "Upgrade");
        }
예제 #3
0
파일: WebSocket.cs 프로젝트: yankaics/cms-1
 internal WebSocket(TcpListenerWebSocketContext context)
     : this()
 {
     _uri       = Ext.ToUri(context.Path);
     _context   = context;
     _tcpClient = context.Client;
     _wsStream  = context.Stream;
     _endPoint  = context.ServerEndPoint;
     _isClient  = false;
     _isSecure  = context.IsSecureConnection;
 }