예제 #1
0
파일: HttpUtil.cs 프로젝트: wxlonstar/Fenix
        public static long GetContentLength(IHttpMessage message)
        {
            if (message.Headers.TryGet(HttpHeaderNames.ContentLength, out ICharSequence value))
            {
                return(CharUtil.ParseLong(value));
            }

            // We know the content length if it's a Web Socket message even if
            // Content-Length header is missing.
            long webSocketContentLength = GetWebSocketContentLength(message);

            if (webSocketContentLength >= 0)
            {
                return(webSocketContentLength);
            }

            // Otherwise we don't.
            return(ThrowHelper.ThrowFormatException_HeaderNotFound());
        }