[Modify] Add a check for the Content-Length header
This commit is contained in:
parent
7ec5daf80b
commit
35e88eed3d
@ -63,6 +63,7 @@ namespace WebSocketSharp.Net
|
|||||||
private HttpConnection _connection;
|
private HttpConnection _connection;
|
||||||
private Encoding _contentEncoding;
|
private Encoding _contentEncoding;
|
||||||
private long _contentLength;
|
private long _contentLength;
|
||||||
|
private bool _contentLengthSet;
|
||||||
private HttpListenerContext _context;
|
private HttpListenerContext _context;
|
||||||
private CookieCollection _cookies;
|
private CookieCollection _cookies;
|
||||||
private WebHeaderCollection _headers;
|
private WebHeaderCollection _headers;
|
||||||
@ -612,6 +613,11 @@ namespace WebSocketSharp.Net
|
|||||||
|
|
||||||
var lower = name.ToLower (CultureInfo.InvariantCulture);
|
var lower = name.ToLower (CultureInfo.InvariantCulture);
|
||||||
if (lower == "content-length") {
|
if (lower == "content-length") {
|
||||||
|
if (_contentLengthSet) {
|
||||||
|
_context.ErrorMessage = "Invalid Content-Length header";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
long len;
|
long len;
|
||||||
if (!Int64.TryParse (val, out len)) {
|
if (!Int64.TryParse (val, out len)) {
|
||||||
_context.ErrorMessage = "Invalid Content-Length header";
|
_context.ErrorMessage = "Invalid Content-Length header";
|
||||||
@ -624,6 +630,8 @@ namespace WebSocketSharp.Net
|
|||||||
}
|
}
|
||||||
|
|
||||||
_contentLength = len;
|
_contentLength = len;
|
||||||
|
_contentLengthSet = true;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user