Read() public static method

ストリームからHTTPリクエストを読み取り解析します
/// HTTPリクエストの終端より前に解析ストリームの末尾に到達した /// /// HTTPリクエストが不正な形式であった ///
public static Read ( Stream stream ) : HTTPRequest
stream Stream 読み取り元のストリーム
return HTTPRequest
Esempio n. 1
0
        /// <summary>
        /// HTTPリクエストを解析します
        /// </summary>
        /// <param name="header">リクエスト</param>
        /// <returns>
        /// 解析できた場合はHTTPRequest、それ以外はnull
        /// </returns>
        private HTTPRequest ParseRequest(byte[] header)
        {
            HTTPRequest res    = null;
            var         stream = new MemoryStream(header);

            try {
                res = HTTPRequestReader.Read(stream);
            }
            catch (EndOfStreamException) {
            }
            stream.Close();
            return(res);
        }
 public override Guid?ParseChannelID(byte[] header)
 {
     using (var stream = new MemoryStream(header)) {
         var res = HTTPRequestReader.Read(stream);
         if (res != null)
         {
             return(Guid.Empty);
         }
         else
         {
             return(null);
         }
     }
 }
 public override IOutputStream Create(
     Stream input_stream,
     Stream output_stream,
     EndPoint remote_endpoint,
     AccessControlInfo access_control,
     Guid channel_id,
     byte[] header)
 {
     using (var stream = new MemoryStream(header)) {
         var req = HTTPRequestReader.Read(stream);
         return(new HTTPDummyOutputStream(
                    PeerCast,
                    input_stream,
                    output_stream,
                    remote_endpoint,
                    access_control,
                    req));
     }
 }
        public override Guid?ParseChannelID(byte[] header)
        {
            HTTPRequest res    = null;
            var         stream = new MemoryStream(header);

            try {
                res = HTTPRequestReader.Read(stream);
            }
            catch (EndOfStreamException) {
            }
            stream.Close();
            if (res != null)
            {
                return(Guid.Empty);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 5
0
        public override IOutputStream Create(
            Stream input_stream,
            Stream output_stream,
            EndPoint remote_endpoint,
            AccessControlInfo access_control,
            Guid channel_id,
            byte[] header)
        {
            HTTPRequest req    = null;
            var         stream = new MemoryStream(header);

            try {
                req = HTTPRequestReader.Read(stream);
            }
            catch (EndOfStreamException) {
            }
            return(new HTTPDummyOutputStream(
                       PeerCast,
                       input_stream,
                       output_stream,
                       remote_endpoint,
                       access_control,
                       req));
        }
Esempio n. 6
0
 /// <summary>
 /// HTTPリクエストを解析します
 /// </summary>
 /// <param name="header">リクエスト</param>
 /// <returns>
 /// 解析できた場合はHTTPRequest、それ以外はnull
 /// </returns>
 private HTTPRequest ParseRequest(byte[] header)
 {
     using (var stream = new MemoryStream(header)) {
         return(HTTPRequestReader.Read(stream));
     }
 }