Пример #1
0
 /// <summary>
 /// Return stream which at first gives bytes from header encoded given encoding
 /// and when it ends read bytes from given string
 /// </summary>
 /// <param name="header"></param>
 /// <param name="stream"></param>
 public HTTPResponse(HTTPResponseHeader header, Stream stream, Encoding encoding)
 {
     try
     {
         _streamLength = stream.Length;
     }
     catch (NotSupportedException)
     {
         throw new StreamTypeException(LENGTH_ERROR_MESSAGE);
     }
     header.SetField(HTTPResponseHeader.CONTENT_LENGTH_FIELD, _streamLength.ToString());
     this._header = encoding.GetBytes(header.ToString());
     if (!stream.CanRead)
     {
         throw new StreamTypeException(READ_ERROR_MESSAGE);
     }
     internalStream = stream;
     _position = 0;
     _headerLength = this._header.LongLength;
 }
Пример #2
0
 /// <summary>
 /// Return stream which at first gives bytes from header encoded given encoding
 /// and when it ends read bytes from given string
 /// </summary>
 /// <param name="header"></param>
 /// <param name="stream"></param>
 public HTTPResponse(HTTPResponseHeader header, Stream stream, Encoding encoding)
 {
     try
     {
         _streamLength = stream.Length;
     }
     catch (NotSupportedException)
     {
         throw new StreamTypeException(LENGTH_ERROR_MESSAGE);
     }
     header.SetField(HTTPResponseHeader.CONTENT_LENGTH_FIELD, _streamLength.ToString());
     this._header = encoding.GetBytes(header.ToString());
     if (!stream.CanRead)
     {
         throw new StreamTypeException(READ_ERROR_MESSAGE);
     }
     internalStream = stream;
     _position      = 0;
     _headerLength  = this._header.LongLength;
 }