public static HTTPServerHandshake GetBadRequest(Dictionary<string, string> extras = null) { if (extras == null) extras = new Dictionary<string, string>(); HTTPServerHandshake response = new HTTPServerHandshake(); response.Status = "400 Bad Request"; response.ExtraFields = extras; return response; }
/// <summary> /// Writes the server response handshake async. /// </summary> /// <returns>The handshake async.</returns> /// <param name="handshake">Handshake.</param> public async Task<DataStatus> WriteHandshakeAsync(HTTPServerHandshake handshake) { return await WriteRawAsync(System.Text.Encoding.ASCII.GetBytes(handshake.ToString())); }
public static HTTPServerHandshake GetResponseForClientHandshake(HTTPClientHandshake handshake) { HTTPServerHandshake response = new HTTPServerHandshake(); response.AcceptedProtocols = new List<string>(handshake.Protocols); response.AcceptedExtensions = new List<string>(handshake.Extensions); response.AcceptKey = GenerateAcceptKey(handshake.Key); response.HTTPVersion = handshake.HTTPVersion; response.Status = "101 Switching Protocols"; return response; }
/// <summary> /// Handshakes are a bit special, so use this to enqueue them. /// </summary> /// <param name="handshake">Handshake.</param> public void QueueHandshakeMessage(HTTPServerHandshake handshake) { QueueRaw(System.Text.Encoding.ASCII.GetBytes(handshake.ToString())); //QueueMessage(handshake.ToString(), System.Text.Encoding.ASCII); }