クライアントからのHTTPリクエスト内容を保持するクラスです
 public HTTPDummyOutputStream(
     PeerCast peercast,
     Stream input_stream,
     Stream output_stream,
     EndPoint remote_endpoint,
     AccessControlInfo access_control,
     HTTPRequest req)
     : base(peercast, input_stream, output_stream, remote_endpoint, access_control, null, null)
 {
     Logger.Debug("Initialized: Remote {0}", remote_endpoint);
       this.request = req;
 }
Example #2
0
 public AdminHostOutputStream(
     AdminHost owner,
     PeerCast peercast,
     Stream input_stream,
     Stream output_stream,
     EndPoint remote_endpoint,
     AccessControlInfo access_control,
     HTTPRequest request)
     : base(peercast, input_stream, output_stream, remote_endpoint, access_control, null, null)
 {
     this.owner   = owner;
     this.request = request;
     Logger.Debug("Initialized: Remote {0}", remote_endpoint);
 }
Example #3
0
 public APIHostOutputStream(
     APIHost owner,
     PeerCast peercast,
     Stream input_stream,
     Stream output_stream,
     EndPoint remote_endpoint,
     HTTPRequest request,
     byte[] header)
     : base(peercast, input_stream, output_stream, remote_endpoint, null, header)
 {
     this.owner   = owner;
     this.request = request;
     this.rpcHost = new JSONRPCHost(this);
     Logger.Debug("Initialized: Remote {0}", remote_endpoint);
 }
 /// <summary>
 /// 元になるストリーム、チャンネル、リクエストからHTTPOutputStreamを初期化します
 /// </summary>
 /// <param name="peercast">所属するPeerCast</param>
 /// <param name="input_stream">元になる受信ストリーム</param>
 /// <param name="output_stream">元になる送信ストリーム</param>
 /// <param name="is_local">接続先がローカルネットワーク内かどうか</param>
 /// <param name="channel">所属するチャンネル。無い場合はnull</param>
 /// <param name="request">クライアントからのリクエスト</param>
 public HTTPOutputStream(
     PeerCast peercast,
     Stream input_stream,
     Stream output_stream,
     EndPoint remote_endpoint,
     Channel channel,
     HTTPRequest request)
     : base(peercast, input_stream, output_stream, remote_endpoint, channel, null)
 {
     Logger.Debug("Initialized: Channel {0}, Remote {1}, Request {2} {3}",
     channel!=null ? channel.ChannelID.ToString("N") : "(null)",
     remote_endpoint,
     request.Method,
     request.Uri);
       this.request = request;
 }
 /// <summary>
 /// ストリームからHTTPリクエストを読み取り解析します
 /// </summary>
 /// <param name="stream">読み取り元のストリーム</param>
 /// <returns>解析済みHTTPRequest</returns>
 /// <exception cref="EndOfStreamException">
 /// HTTPリクエストの終端より前に解析ストリームの末尾に到達した
 /// </exception>
 /// <exception cref="InvalidDataException">
 /// HTTPリクエストが不正な形式であった
 /// </exception>
 public static HTTPRequest Read(Stream stream)
 {
     string line = null;
       var requests = new List<string>();
       var buf = new List<byte>();
       while (line!="") {
     var value = stream.ReadByte();
     if (value<0) {
       throw new EndOfStreamException();
     }
     buf.Add((byte)value);
     if (buf.Count >= 2 && buf[buf.Count - 2] == '\r' && buf[buf.Count - 1] == '\n') {
       line = System.Text.Encoding.UTF8.GetString(buf.ToArray(), 0, buf.Count - 2);
       if (line!="") requests.Add(line);
       buf.Clear();
     }
       }
       var req = new HTTPRequest(requests);
       if (req.Uri==null) throw new InvalidDataException();
       return req;
 }