예제 #1
0
 public void SipMethodの解釈(string str, SipMethod sipMethod)
 {
     //setup
     var sut = new StartLine(Encoding.ASCII.GetBytes(str));
     var exception = sipMethod;
     //exercise
     var actual = sut.SipMethod;
     //verify
     Assert.That(actual, Is.EqualTo(exception));
 }
예제 #2
0
 public void RequestUriの解釈(string str, string requestUri)
 {
     //setup
     var sut = new StartLine(Encoding.ASCII.GetBytes(str));
     var exception = requestUri;
     //exercise
     var actual = sut.RequestUri;
     //verify
     Assert.That(actual, Is.EqualTo(exception));
 }
예제 #3
0
        public Reception(byte[] buf)
        {
            //とりあえず、エラーを返せるように全てを初期化する
            Body      = new List <byte[]>();
            Header    = new Header();
            StartLine = new StartLine(null);

            var lines = Inet.GetLines(buf);

            if (lines.Count == 0)
            {
                return; //スタートラインが存在しない
            }
            StartLine = new StartLine(lines[0]);
            if (StartLine.ReceptionKind == ReceptionKind.Unknown)
            {
                return; //スタートラインが無効な場合、これ以降の処理を行わない
            }
            //ヘッダ初期化
            var header = new List <byte[]>();
            var i      = 1; //処理対象の行をカウントする

            for (; i < lines.Count; i++)
            {
                if (lines[i].Length == 2 && lines[i][0] == '\r' && lines[i][1] == '\n')
                {
                    //改行のみの行
                    i++;
                    break;
                }
                header.Add(lines[i]);
            }
            //ヘッダ初期化
            Header = new Header(header);

            //ボディ初期化
            var contentLength = Header.GetVal("Content-Length");

            if (contentLength == "0")
            {
                return;
            }

            for (; i < lines.Count; i++)
            {
                Body.Add(lines[i]);
            }
        }
예제 #4
0
파일: Reception.cs 프로젝트: jsakamoto/bjd5
        public Reception(byte[] buf)
        {
            //とりあえず、エラーを返せるように全てを初期化する
            Body = new List<byte[]>();
            Header = new Header();
            StartLine = new StartLine(null);

            var lines = Inet.GetLines(buf);
            if (lines.Count == 0){
                return; //スタートラインが存在しない
            }
            StartLine = new StartLine(lines[0]);
            if (StartLine.ReceptionKind == ReceptionKind.Unknown) {
                return; //スタートラインが無効な場合、これ以降の処理を行わない
            }
            //ヘッダ初期化
            var header = new List<byte[]>();
            var i = 1; //処理対象の行をカウントする
            for (; i < lines.Count; i++){
                if (lines[i].Length == 2 && lines[i][0] == '\r' && lines[i][1] == '\n'){
                    //改行のみの行
                    i++;
                    break;
                }
                header.Add(lines[i]);
            }
            //ヘッダ初期化
            Header = new Header(header);

            //ボディ初期化
            var contentLength = Header.GetVal("Content-Length");
            if (contentLength == "0")
                return;

            for (;i<lines.Count;i++) {
                Body.Add(lines[i]);
            }
        }
예제 #5
0
 public void SipVerの解釈(string str, float no)
 {
     //setup
     var sut = new StartLine(Encoding.ASCII.GetBytes(str));
     var exception = no;
     //exercise
     var actual = sut.SipVer.No;
     //verify
     Assert.That(actual, Is.EqualTo(exception));
 }
예제 #6
0
 public void Statusコードの解釈(string str, int statusCode)
 {
     //setup
     var sut = new StartLine(Encoding.ASCII.GetBytes(str));
     var exception = statusCode;
     //exercise
     var actual = sut.StatusCode;
     //verify
     Assert.That(actual, Is.EqualTo(exception));
 }