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)) }); }
public RequestHandshake(string uriString) { HttpMethod = "GET"; RequestUri = Ext.ToUri(uriString); AddHeader("Upgrade", "websocket"); AddHeader("Connection", "Upgrade"); }
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; }