|
|
|
@ -59,14 +59,9 @@ namespace WebSocketSharp.Net
|
|
|
|
[ComVisible (true)]
|
|
|
|
[ComVisible (true)]
|
|
|
|
public class WebHeaderCollection : NameValueCollection, ISerializable
|
|
|
|
public class WebHeaderCollection : NameValueCollection, ISerializable
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#region Private Static Fields
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static readonly Dictionary<string, HttpHeaderInfo> _headers;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Private Fields
|
|
|
|
#region Private Fields
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static readonly Dictionary<string, HttpHeaderInfo> _headers;
|
|
|
|
private bool _internallyCreated;
|
|
|
|
private bool _internallyCreated;
|
|
|
|
private HttpHeaderType _state;
|
|
|
|
private HttpHeaderType _state;
|
|
|
|
|
|
|
|
|
|
|
|
@ -557,11 +552,11 @@ namespace WebSocketSharp.Net
|
|
|
|
_internallyCreated = serializationInfo.GetBoolean ("InternallyCreated");
|
|
|
|
_internallyCreated = serializationInfo.GetBoolean ("InternallyCreated");
|
|
|
|
_state = (HttpHeaderType) serializationInfo.GetInt32 ("State");
|
|
|
|
_state = (HttpHeaderType) serializationInfo.GetInt32 ("State");
|
|
|
|
|
|
|
|
|
|
|
|
var count = serializationInfo.GetInt32 ("Count");
|
|
|
|
var cnt = serializationInfo.GetInt32 ("Count");
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
for (var i = 0; i < cnt; i++) {
|
|
|
|
base.Add (
|
|
|
|
base.Add (
|
|
|
|
serializationInfo.GetString (i.ToString ()),
|
|
|
|
serializationInfo.GetString (i.ToString ()),
|
|
|
|
serializationInfo.GetString ((count + i).ToString ()));
|
|
|
|
serializationInfo.GetString ((cnt + i).ToString ()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (SerializationException ex) {
|
|
|
|
catch (SerializationException ex) {
|
|
|
|
@ -578,7 +573,6 @@ namespace WebSocketSharp.Net
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public WebHeaderCollection ()
|
|
|
|
public WebHeaderCollection ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_internallyCreated = false;
|
|
|
|
|
|
|
|
_state = HttpHeaderType.Unspecified;
|
|
|
|
_state = HttpHeaderType.Unspecified;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -705,11 +699,9 @@ namespace WebSocketSharp.Net
|
|
|
|
|
|
|
|
|
|
|
|
private void add (string name, string value, bool ignoreRestricted)
|
|
|
|
private void add (string name, string value, bool ignoreRestricted)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Action <string, string> act;
|
|
|
|
var act = ignoreRestricted
|
|
|
|
if (ignoreRestricted)
|
|
|
|
? (Action <string, string>) addWithoutCheckingNameAndRestricted
|
|
|
|
act = addWithoutCheckingNameAndRestricted;
|
|
|
|
: addWithoutCheckingName;
|
|
|
|
else
|
|
|
|
|
|
|
|
act = addWithoutCheckingName;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
doWithCheckingState (act, checkName (name), value, true);
|
|
|
|
doWithCheckingState (act, checkName (name), value, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -728,7 +720,7 @@ namespace WebSocketSharp.Net
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var i = header.IndexOf (':');
|
|
|
|
var i = header.IndexOf (':');
|
|
|
|
if (i == -1)
|
|
|
|
if (i == -1)
|
|
|
|
throw new ArgumentException ("No colon found.", "header");
|
|
|
|
throw new ArgumentException ("No colon could be found.", "header");
|
|
|
|
|
|
|
|
|
|
|
|
return i;
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -867,6 +859,26 @@ namespace WebSocketSharp.Net
|
|
|
|
return convert (header.ToString ());
|
|
|
|
return convert (header.ToString ());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal void InternalRemove (string name)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
base.Remove (name);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal void InternalSet (string header, bool response)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var pos = checkColonSeparated (header);
|
|
|
|
|
|
|
|
InternalSet (header.Substring (0, pos), header.Substring (pos + 1), response);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal void InternalSet (string name, string value, bool response)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
value = checkValue (value);
|
|
|
|
|
|
|
|
if (IsMultiValue (name, response))
|
|
|
|
|
|
|
|
base.Add (name, value);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
base.Set (name, value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
internal static bool IsHeaderName (string name)
|
|
|
|
internal static bool IsHeaderName (string name)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return name != null && name.Length > 0 && name.IsToken ();
|
|
|
|
return name != null && name.Length > 0 && name.IsToken ();
|
|
|
|
@ -886,26 +898,6 @@ namespace WebSocketSharp.Net
|
|
|
|
return info != null && info.IsMultiValue (response);
|
|
|
|
return info != null && info.IsMultiValue (response);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
internal void RemoveInternally (string name)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
base.Remove (name);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal void SetInternally (string header, bool response)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var pos = checkColonSeparated (header);
|
|
|
|
|
|
|
|
SetInternally (header.Substring (0, pos), header.Substring (pos + 1), response);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal void SetInternally (string name, string value, bool response)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
value = checkValue (value);
|
|
|
|
|
|
|
|
if (IsMultiValue (name, response))
|
|
|
|
|
|
|
|
base.Add (name, value);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
base.Set (name, value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal string ToStringMultiValue (bool response)
|
|
|
|
internal string ToStringMultiValue (bool response)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var buff = new StringBuilder ();
|
|
|
|
var buff = new StringBuilder ();
|
|
|
|
@ -913,8 +905,8 @@ namespace WebSocketSharp.Net
|
|
|
|
i => {
|
|
|
|
i => {
|
|
|
|
var key = GetKey (i);
|
|
|
|
var key = GetKey (i);
|
|
|
|
if (IsMultiValue (key, response))
|
|
|
|
if (IsMultiValue (key, response))
|
|
|
|
foreach (var value in GetValues (i))
|
|
|
|
foreach (var val in GetValues (i))
|
|
|
|
buff.AppendFormat ("{0}: {1}\r\n", key, value);
|
|
|
|
buff.AppendFormat ("{0}: {1}\r\n", key, val);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
buff.AppendFormat ("{0}: {1}\r\n", key, Get (i));
|
|
|
|
buff.AppendFormat ("{0}: {1}\r\n", key, Get (i));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
@ -963,7 +955,7 @@ namespace WebSocketSharp.Net
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="header">
|
|
|
|
/// <param name="header">
|
|
|
|
/// A <see cref="string"/> that represents the header with the name and value separated by
|
|
|
|
/// A <see cref="string"/> that represents the header with the name and value separated by
|
|
|
|
/// a colon (<c>:</c>).
|
|
|
|
/// a colon (<c>':'</c>).
|
|
|
|
/// </param>
|
|
|
|
/// </param>
|
|
|
|
/// <exception cref="ArgumentNullException">
|
|
|
|
/// <exception cref="ArgumentNullException">
|
|
|
|
/// <paramref name="header"/> is <see langword="null"/>, empty, or the name part of
|
|
|
|
/// <paramref name="header"/> is <see langword="null"/>, empty, or the name part of
|
|
|
|
@ -1191,9 +1183,9 @@ namespace WebSocketSharp.Net
|
|
|
|
/// </exception>
|
|
|
|
/// </exception>
|
|
|
|
public override string[] GetValues (int index)
|
|
|
|
public override string[] GetValues (int index)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var values = base.GetValues (index);
|
|
|
|
var vals = base.GetValues (index);
|
|
|
|
return values != null && values.Length > 0
|
|
|
|
return vals != null && vals.Length > 0
|
|
|
|
? values
|
|
|
|
? vals
|
|
|
|
: null;
|
|
|
|
: null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1209,9 +1201,9 @@ namespace WebSocketSharp.Net
|
|
|
|
/// </param>
|
|
|
|
/// </param>
|
|
|
|
public override string[] GetValues (string header)
|
|
|
|
public override string[] GetValues (string header)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var values = base.GetValues (header);
|
|
|
|
var vals = base.GetValues (header);
|
|
|
|
return values != null && values.Length > 0
|
|
|
|
return vals != null && vals.Length > 0
|
|
|
|
? values
|
|
|
|
? vals
|
|
|
|
: null;
|
|
|
|
: null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1239,12 +1231,12 @@ namespace WebSocketSharp.Net
|
|
|
|
serializationInfo.AddValue ("InternallyCreated", _internallyCreated);
|
|
|
|
serializationInfo.AddValue ("InternallyCreated", _internallyCreated);
|
|
|
|
serializationInfo.AddValue ("State", (int) _state);
|
|
|
|
serializationInfo.AddValue ("State", (int) _state);
|
|
|
|
|
|
|
|
|
|
|
|
var count = Count;
|
|
|
|
var cnt = Count;
|
|
|
|
serializationInfo.AddValue ("Count", count);
|
|
|
|
serializationInfo.AddValue ("Count", cnt);
|
|
|
|
count.Times (
|
|
|
|
cnt.Times (
|
|
|
|
i => {
|
|
|
|
i => {
|
|
|
|
serializationInfo.AddValue (i.ToString (), GetKey (i));
|
|
|
|
serializationInfo.AddValue (i.ToString (), GetKey (i));
|
|
|
|
serializationInfo.AddValue ((count + i).ToString (), Get (i));
|
|
|
|
serializationInfo.AddValue ((cnt + i).ToString (), Get (i));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1499,7 +1491,7 @@ namespace WebSocketSharp.Net
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Explicit Interface Implementation
|
|
|
|
#region Explicit Interface Implementations
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Populates the specified <see cref="SerializationInfo"/> with the data needed to serialize
|
|
|
|
/// Populates the specified <see cref="SerializationInfo"/> with the data needed to serialize
|
|
|
|
|