BytesRoad.Net.Sockets.Socket_HttpConnect.AnalyzeReply C# (CSharp) Method

AnalyzeReply() private method

private AnalyzeReply ( ByteVector reply, string &reason ) : int
reply ByteVector
reason string
return int
        int AnalyzeReply(ByteVector reply, out string reason)
        {
            if(0 == reply.Size)
                throw new SocketException(SockErrors.WSAECONNREFUSED);

                // throw new ProxyErrorException("Web proxy close the connection.");

            // reply should be in following form:
            // "HTTP/x.x xxx reason(\r)?\n"
            string replyStr = Encoding.ASCII.GetString(reply.Data, 0, reply.Size);
            Match m = _replyRegEx.Match(replyStr);

            if((reply.Size < 14) || (m.Groups.Count != 4))
                throw new ProtocolViolationException("Web proxy reply is incorrect.");

            int code = int.Parse(m.Groups["code"].Value);
            reason = m.Groups["reason"].Value;

            return code;
        }