|
|
|
@ -62,14 +62,14 @@ namespace WebSocketSharp.Net
|
|
|
|
private bool _chunked;
|
|
|
|
private bool _chunked;
|
|
|
|
private Encoding _contentEncoding;
|
|
|
|
private Encoding _contentEncoding;
|
|
|
|
private long _contentLength;
|
|
|
|
private long _contentLength;
|
|
|
|
private bool _contentLengthWasSet;
|
|
|
|
private bool _contentLengthSet;
|
|
|
|
private HttpListenerContext _context;
|
|
|
|
private HttpListenerContext _context;
|
|
|
|
private CookieCollection _cookies;
|
|
|
|
private CookieCollection _cookies;
|
|
|
|
private WebHeaderCollection _headers;
|
|
|
|
private WebHeaderCollection _headers;
|
|
|
|
private Guid _identifier;
|
|
|
|
private Guid _identifier;
|
|
|
|
private Stream _inputStream;
|
|
|
|
private Stream _inputStream;
|
|
|
|
private bool _keepAlive;
|
|
|
|
private bool _keepAlive;
|
|
|
|
private bool _keepAliveWasSet;
|
|
|
|
private bool _keepAliveSet;
|
|
|
|
private string _method;
|
|
|
|
private string _method;
|
|
|
|
private NameValueCollection _queryString;
|
|
|
|
private NameValueCollection _queryString;
|
|
|
|
private Uri _referer;
|
|
|
|
private Uri _referer;
|
|
|
|
@ -78,7 +78,7 @@ namespace WebSocketSharp.Net
|
|
|
|
private string[] _userLanguages;
|
|
|
|
private string[] _userLanguages;
|
|
|
|
private Version _version;
|
|
|
|
private Version _version;
|
|
|
|
private bool _websocketRequest;
|
|
|
|
private bool _websocketRequest;
|
|
|
|
private bool _websocketRequestWasSet;
|
|
|
|
private bool _websocketRequestSet;
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
@ -276,13 +276,13 @@ namespace WebSocketSharp.Net
|
|
|
|
/// </value>
|
|
|
|
/// </value>
|
|
|
|
public bool IsWebSocketRequest {
|
|
|
|
public bool IsWebSocketRequest {
|
|
|
|
get {
|
|
|
|
get {
|
|
|
|
if (!_websocketRequestWasSet) {
|
|
|
|
if (!_websocketRequestSet) {
|
|
|
|
_websocketRequest = _method == "GET" &&
|
|
|
|
_websocketRequest = _method == "GET" &&
|
|
|
|
_version > HttpVersion.Version10 &&
|
|
|
|
_version > HttpVersion.Version10 &&
|
|
|
|
_headers.Contains ("Upgrade", "websocket") &&
|
|
|
|
_headers.Contains ("Upgrade", "websocket") &&
|
|
|
|
_headers.Contains ("Connection", "Upgrade");
|
|
|
|
_headers.Contains ("Connection", "Upgrade");
|
|
|
|
|
|
|
|
|
|
|
|
_websocketRequestWasSet = true;
|
|
|
|
_websocketRequestSet = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return _websocketRequest;
|
|
|
|
return _websocketRequest;
|
|
|
|
@ -297,13 +297,13 @@ namespace WebSocketSharp.Net
|
|
|
|
/// </value>
|
|
|
|
/// </value>
|
|
|
|
public bool KeepAlive {
|
|
|
|
public bool KeepAlive {
|
|
|
|
get {
|
|
|
|
get {
|
|
|
|
if (!_keepAliveWasSet) {
|
|
|
|
if (!_keepAliveSet) {
|
|
|
|
string keepAlive;
|
|
|
|
string keepAlive;
|
|
|
|
_keepAlive = _version > HttpVersion.Version10 ||
|
|
|
|
_keepAlive = _version > HttpVersion.Version10 ||
|
|
|
|
_headers.Contains ("Connection", "keep-alive") ||
|
|
|
|
_headers.Contains ("Connection", "keep-alive") ||
|
|
|
|
((keepAlive = _headers["Keep-Alive"]) != null && keepAlive != "closed");
|
|
|
|
((keepAlive = _headers["Keep-Alive"]) != null && keepAlive != "closed");
|
|
|
|
|
|
|
|
|
|
|
|
_keepAliveWasSet = true;
|
|
|
|
_keepAliveSet = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return _keepAlive;
|
|
|
|
return _keepAlive;
|
|
|
|
@ -505,7 +505,7 @@ namespace WebSocketSharp.Net
|
|
|
|
long len;
|
|
|
|
long len;
|
|
|
|
if (Int64.TryParse (val, out len) && len >= 0) {
|
|
|
|
if (Int64.TryParse (val, out len) && len >= 0) {
|
|
|
|
_contentLength = len;
|
|
|
|
_contentLength = len;
|
|
|
|
_contentLengthWasSet = true;
|
|
|
|
_contentLengthSet = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
_context.ErrorMessage = "Invalid Content-Length header";
|
|
|
|
_context.ErrorMessage = "Invalid Content-Length header";
|
|
|
|
@ -558,7 +558,7 @@ namespace WebSocketSharp.Net
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!_chunked && !_contentLengthWasSet) {
|
|
|
|
if (!_chunked && !_contentLengthSet) {
|
|
|
|
var method = _method.ToLower ();
|
|
|
|
var method = _method.ToLower ();
|
|
|
|
if (method == "post" || method == "put") {
|
|
|
|
if (method == "post" || method == "put") {
|
|
|
|
_context.ErrorMessage = String.Empty;
|
|
|
|
_context.ErrorMessage = String.Empty;
|
|
|
|
|