|
|
|
@ -27,6 +27,7 @@
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
using System.Text;
|
|
|
|
using System.Text;
|
|
|
|
using WebSocketSharp.Net;
|
|
|
|
using WebSocketSharp.Net;
|
|
|
|
|
|
|
|
|
|
|
|
@ -43,15 +44,17 @@ namespace WebSocketSharp
|
|
|
|
|
|
|
|
|
|
|
|
#region Private Constructors
|
|
|
|
#region Private Constructors
|
|
|
|
|
|
|
|
|
|
|
|
private HandshakeResponse ()
|
|
|
|
private HandshakeResponse (Version version, NameValueCollection headers)
|
|
|
|
|
|
|
|
: base (version, headers)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Public Constructors
|
|
|
|
#region Internal Constructors
|
|
|
|
|
|
|
|
|
|
|
|
public HandshakeResponse (HttpStatusCode code)
|
|
|
|
internal HandshakeResponse (HttpStatusCode code)
|
|
|
|
|
|
|
|
: base (HttpVersion.Version11, new NameValueCollection ())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_code = ((int) code).ToString ();
|
|
|
|
_code = ((int) code).ToString ();
|
|
|
|
_reason = code.GetDescription ();
|
|
|
|
_reason = code.GetDescription ();
|
|
|
|
@ -103,27 +106,19 @@ namespace WebSocketSharp
|
|
|
|
get {
|
|
|
|
get {
|
|
|
|
return _reason;
|
|
|
|
return _reason;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private set {
|
|
|
|
|
|
|
|
_reason = value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string StatusCode {
|
|
|
|
public string StatusCode {
|
|
|
|
get {
|
|
|
|
get {
|
|
|
|
return _code;
|
|
|
|
return _code;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private set {
|
|
|
|
|
|
|
|
_code = value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Public Methods
|
|
|
|
#region Internal Methods
|
|
|
|
|
|
|
|
|
|
|
|
public static HandshakeResponse CreateCloseResponse (HttpStatusCode code)
|
|
|
|
internal static HandshakeResponse CreateCloseResponse (HttpStatusCode code)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var res = new HandshakeResponse (code);
|
|
|
|
var res = new HandshakeResponse (code);
|
|
|
|
res.Headers["Connection"] = "close";
|
|
|
|
res.Headers["Connection"] = "close";
|
|
|
|
@ -131,7 +126,7 @@ namespace WebSocketSharp
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static HandshakeResponse Parse (string[] headerParts)
|
|
|
|
internal static HandshakeResponse Parse (string[] headerParts)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var statusLine = headerParts[0].Split (new[] { ' ' }, 3);
|
|
|
|
var statusLine = headerParts[0].Split (new[] { ' ' }, 3);
|
|
|
|
if (statusLine.Length != 3)
|
|
|
|
if (statusLine.Length != 3)
|
|
|
|
@ -141,14 +136,17 @@ namespace WebSocketSharp
|
|
|
|
for (int i = 1; i < headerParts.Length; i++)
|
|
|
|
for (int i = 1; i < headerParts.Length; i++)
|
|
|
|
headers.SetInternally (headerParts[i], true);
|
|
|
|
headers.SetInternally (headerParts[i], true);
|
|
|
|
|
|
|
|
|
|
|
|
return new HandshakeResponse {
|
|
|
|
var res = new HandshakeResponse (new Version (statusLine[0].Substring (5)), headers);
|
|
|
|
Headers = headers,
|
|
|
|
res._code = statusLine[1];
|
|
|
|
ProtocolVersion = new Version (statusLine[0].Substring (5)),
|
|
|
|
res._reason = statusLine[2];
|
|
|
|
Reason = statusLine[2],
|
|
|
|
|
|
|
|
StatusCode = statusLine[1]
|
|
|
|
return res;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Public Methods
|
|
|
|
|
|
|
|
|
|
|
|
public void SetCookies (CookieCollection cookies)
|
|
|
|
public void SetCookies (CookieCollection cookies)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (cookies == null || cookies.Count == 0)
|
|
|
|
if (cookies == null || cookies.Count == 0)
|
|
|
|
|