Fix due to the modified Ext.cs

This commit is contained in:
sta 2013-05-09 00:41:02 +09:00
parent 8ba6ff1f09
commit 876a017ff0
17 changed files with 71 additions and 68 deletions

Binary file not shown.

View File

@ -13,7 +13,7 @@ namespace Example2 {
private string getName() private string getName()
{ {
return QueryString.Exists("name") return QueryString.Contains("name")
? QueryString["name"] ? QueryString["name"]
: "anon#" + getNum(); : "anon#" + getNum();
} }

View File

@ -9,7 +9,7 @@ namespace Example2 {
{ {
protected override void OnMessage(MessageEventArgs e) protected override void OnMessage(MessageEventArgs e)
{ {
var msg = QueryString.Exists("name") var msg = QueryString.Contains("name")
? String.Format("'{0}' returns to {1}", e.Data, QueryString["name"]) ? String.Format("'{0}' returns to {1}", e.Data, QueryString["name"])
: e.Data; : e.Data;
Send(msg); Send(msg);

View File

@ -13,7 +13,7 @@ namespace Example3 {
private string getName() private string getName()
{ {
return QueryString.Exists("name") return QueryString.Contains("name")
? QueryString["name"] ? QueryString["name"]
: "anon#" + getNum(); : "anon#" + getNum();
} }

View File

@ -8,7 +8,7 @@ namespace Example3 {
{ {
protected override void OnMessage(MessageEventArgs e) protected override void OnMessage(MessageEventArgs e)
{ {
var msg = QueryString.Exists("name") var msg = QueryString.Contains("name")
? String.Format("'{0}' returns to {1}", e.Data, QueryString["name"]) ? String.Format("'{0}' returns to {1}", e.Data, QueryString["name"])
: e.Data; : e.Data;
Send(msg); Send(msg);

View File

@ -479,6 +479,60 @@ namespace WebSocketSharp {
: value.IndexOfAny(chars) != -1; : value.IndexOfAny(chars) != -1;
} }
/// <summary>
/// Determines whether the specified <see cref="NameValueCollection"/> contains the entry
/// with the specified <paramref name="name"/>.
/// </summary>
/// <returns>
/// <c>true</c> if <paramref name="collection"/> contains the entry with <paramref name="name"/>;
/// otherwise, <c>false</c>.
/// </returns>
/// <param name="collection">
/// A <see cref="NameValueCollection"/> that contains the entries.
/// </param>
/// <param name="name">
/// A <see cref="string"/> that contains the key of the entry to find.
/// </param>
public static bool Contains(this NameValueCollection collection, string name)
{
return collection == null
? false
: collection[name] != null;
}
/// <summary>
/// Determines whether the specified <see cref="NameValueCollection"/> contains the entry
/// with the specified both <paramref name="name"/> and <paramref name="value"/>.
/// </summary>
/// <returns>
/// <c>true</c> if <paramref name="collection"/> contains the entry with both <paramref name="name"/> and <paramref name="value"/>;
/// otherwise, <c>false</c>.
/// </returns>
/// <param name="collection">
/// A <see cref="NameValueCollection"/> that contains the entries.
/// </param>
/// <param name="name">
/// A <see cref="string"/> that contains the key of the entry to find.
/// </param>
/// <param name="value">
/// A <see cref="string"/> that contains the value of the entry to find.
/// </param>
public static bool Contains(this NameValueCollection collection, string name, string value)
{
if (collection == null)
return false;
var values = collection[name];
if (values == null)
return false;
foreach (string v in values.Split(','))
if (v.Trim().Equals(value, StringComparison.OrdinalIgnoreCase))
return true;
return false;
}
/// <summary> /// <summary>
/// Emit the specified <see cref="EventHandler"/> delegate if is not <see langword="null"/>. /// Emit the specified <see cref="EventHandler"/> delegate if is not <see langword="null"/>.
/// </summary> /// </summary>
@ -551,56 +605,6 @@ namespace WebSocketSharp {
return b == Convert.ToByte(c); return b == Convert.ToByte(c);
} }
/// <summary>
/// Determines whether the entry with the specified key exists in the specified <see cref="NameValueCollection"/>.
/// </summary>
/// <returns>
/// <c>true</c> if the entry with the <paramref name="name"/> exists in the <paramref name="collection"/>; otherwise, <c>false</c>.
/// </returns>
/// <param name="collection">
/// A <see cref="NameValueCollection"/> that contains the entries.
/// </param>
/// <param name="name">
/// A <see cref="string"/> that contains the key of the entry to find.
/// </param>
public static bool Exists(this NameValueCollection collection, string name)
{
return collection == null
? false
: collection[name] != null;
}
/// <summary>
/// Determines whether the entry with the specified both key and value exists in the specified <see cref="NameValueCollection"/>.
/// </summary>
/// <returns>
/// <c>true</c> if the entry with the both <paramref name="name"/> and <paramref name="value"/> exists in the <paramref name="collection"/>; otherwise, <c>false</c>.
/// </returns>
/// <param name="collection">
/// A <see cref="NameValueCollection"/> that contains the entries.
/// </param>
/// <param name="name">
/// A <see cref="string"/> that contains the key of the entry to find.
/// </param>
/// <param name="value">
/// A <see cref="string"/> that contains the value of the entry to find.
/// </param>
public static bool Exists(this NameValueCollection collection, string name, string value)
{
if (collection == null)
return false;
var values = collection[name];
if (values == null)
return false;
foreach (string v in values.Split(','))
if (String.Compare(v.Trim(), value, true) == 0)
return true;
return false;
}
/// <summary> /// <summary>
/// Gets the absolute path from the specified <see cref="Uri"/>. /// Gets the absolute path from the specified <see cref="Uri"/>.
/// </summary> /// </summary>
@ -645,10 +649,9 @@ namespace WebSocketSharp {
public static CookieCollection GetCookies(this NameValueCollection headers, bool response) public static CookieCollection GetCookies(this NameValueCollection headers, bool response)
{ {
var name = response ? "Set-Cookie" : "Cookie"; var name = response ? "Set-Cookie" : "Cookie";
if (headers == null || !headers.Exists(name)) return headers == null || !headers.Contains(name)
return new CookieCollection(); ? new CookieCollection()
: CookieCollection.Parse(headers[name], response);
return CookieCollection.Parse(headers[name], response);
} }
/// <summary> /// <summary>
@ -999,10 +1002,10 @@ namespace WebSocketSharp {
if (protocol.Length == 0) if (protocol.Length == 0)
throw new ArgumentException("Must not be empty.", "protocol"); throw new ArgumentException("Must not be empty.", "protocol");
if (!request.Headers.Exists("Upgrade", protocol)) if (!request.Headers.Contains("Upgrade", protocol))
return false; return false;
if (!request.Headers.Exists("Connection", "Upgrade")) if (!request.Headers.Contains("Connection", "Upgrade"))
return false; return false;
return true; return true;

View File

@ -72,12 +72,12 @@ namespace WebSocketSharp {
public bool ContainsHeader(string name) public bool ContainsHeader(string name)
{ {
return Headers.Exists(name); return Headers.Contains(name);
} }
public bool ContainsHeader(string name, string value) public bool ContainsHeader(string name, string value)
{ {
return Headers.Exists(name, value); return Headers.Contains(name, value);
} }
public string[] GetHeaderValues(string name) public string[] GetHeaderValues(string name)

View File

@ -265,15 +265,15 @@ namespace WebSocketSharp.Net {
? false ? false
: version < HttpVersion.Version11 : version < HttpVersion.Version11
? false ? false
: !headers.Exists("Upgrade", "websocket") : !headers.Contains("Upgrade", "websocket")
? false ? false
: !headers.Exists("Connection", "Upgrade") : !headers.Contains("Connection", "Upgrade")
? false ? false
: !headers.Exists("Host") : !headers.Contains("Host")
? false ? false
: !headers.Exists("Sec-WebSocket-Key") : !headers.Contains("Sec-WebSocket-Key")
? false ? false
: headers.Exists("Sec-WebSocket-Version"); : headers.Contains("Sec-WebSocket-Version");
} }
} }

View File

@ -819,7 +819,7 @@ namespace WebSocketSharp {
? false ? false
: !isValidHostHeader() : !isValidHostHeader()
? false ? false
: _context.Headers.Exists("Sec-WebSocket-Version", _version); : _context.Headers.Contains("Sec-WebSocket-Version", _version);
} }
// As client // As client