Fix a few for HandshakeResponse.cs
This commit is contained in:
parent
9f0f54f4cd
commit
43040feb52
@ -57,10 +57,10 @@ namespace WebSocketSharp
|
|||||||
_reason = code.GetDescription ();
|
_reason = code.GetDescription ();
|
||||||
|
|
||||||
var headers = Headers;
|
var headers = Headers;
|
||||||
headers ["Server"] = "websocket-sharp/1.0";
|
headers["Server"] = "websocket-sharp/1.0";
|
||||||
if (code == HttpStatusCode.SwitchingProtocols) {
|
if (code == HttpStatusCode.SwitchingProtocols) {
|
||||||
headers ["Upgrade"] = "websocket";
|
headers["Upgrade"] = "websocket";
|
||||||
headers ["Connection"] = "Upgrade";
|
headers["Connection"] = "Upgrade";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ namespace WebSocketSharp
|
|||||||
|
|
||||||
public AuthenticationChallenge AuthChallenge {
|
public AuthenticationChallenge AuthChallenge {
|
||||||
get {
|
get {
|
||||||
var auth = Headers ["WWW-Authenticate"];
|
var auth = Headers["WWW-Authenticate"];
|
||||||
return auth != null && auth.Length > 0
|
return auth != null && auth.Length > 0
|
||||||
? AuthenticationChallenge.Parse (auth)
|
? AuthenticationChallenge.Parse (auth)
|
||||||
: null;
|
: null;
|
||||||
@ -126,26 +126,26 @@ namespace WebSocketSharp
|
|||||||
public static HandshakeResponse CreateCloseResponse (HttpStatusCode code)
|
public static HandshakeResponse CreateCloseResponse (HttpStatusCode code)
|
||||||
{
|
{
|
||||||
var res = new HandshakeResponse (code);
|
var res = new HandshakeResponse (code);
|
||||||
res.Headers ["Connection"] = "close";
|
res.Headers["Connection"] = "close";
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandshakeResponse Parse (string [] headerParts)
|
public 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)
|
||||||
throw new ArgumentException ("Invalid status line: " + headerParts [0]);
|
throw new ArgumentException ("Invalid status line: " + headerParts[0]);
|
||||||
|
|
||||||
var headers = new WebHeaderCollection ();
|
var headers = new WebHeaderCollection ();
|
||||||
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 {
|
return new HandshakeResponse {
|
||||||
Headers = headers,
|
Headers = headers,
|
||||||
ProtocolVersion = new Version (statusLine [0].Substring (5)),
|
ProtocolVersion = new Version (statusLine[0].Substring (5)),
|
||||||
Reason = statusLine [2],
|
Reason = statusLine[2],
|
||||||
StatusCode = statusLine [1]
|
StatusCode = statusLine[1]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ namespace WebSocketSharp
|
|||||||
|
|
||||||
var headers = Headers;
|
var headers = Headers;
|
||||||
foreach (var key in headers.AllKeys)
|
foreach (var key in headers.AllKeys)
|
||||||
output.AppendFormat ("{0}: {1}{2}", key, headers [key], CrLf);
|
output.AppendFormat ("{0}: {1}{2}", key, headers[key], CrLf);
|
||||||
|
|
||||||
output.Append (CrLf);
|
output.Append (CrLf);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user