Exemplo n.º 1
0
        /// <summary>
        /// Send the response header and get a stream to which the body can be written.
        /// </summary>
        /// <returns>The Stream for the body.</returns>
        public Stream Send()
        {
            Debug.Assert(_stream == null);

            if (ChunkedTransferEncoding)
            {
                throw new HTTPException("Chunked transfer encoding is not (yet) supported");
            }
            else if (ContentLength != UNKNOWN_CONTENT_LENGTH)
            {
                CountingOutputStream co = new CountingOutputStream();
                Write(co);
                _stream = new HTTPFixedLengthOutputStream(_session, ContentLength + co.Length);
                Write(_stream);
            }
            else
            {
                KeepAlive = false;
                _stream   = new HTTPOutputStream(_session);
                Write(_stream);
            }

            return(_stream);
        }
        /// <summary>
        /// Send the response header and get a stream to which the body can be written.
        /// </summary>
        /// <returns>The Stream for the body.</returns>
        public Stream Send()
        {
            //Debug.Assert(_stream == null);

            if (ChunkedTransferEncoding)
                throw new HTTPException("Chunked transfer encoding is not (yet) supported");
            else if (ContentLength != UNKNOWN_CONTENT_LENGTH)
            {
                CountingOutputStream co = new CountingOutputStream();
                Write(co);
                _stream = new HTTPFixedLengthOutputStream(_session, ContentLength + co.Length);
                Write(_stream);
            }
            else
            {
                KeepAlive = false;
                _stream = new HTTPOutputStream(_session);
                Write(_stream);
            }

            return _stream;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Send the response header and get a stream to which the body can be written.
        /// </summary>
        /// <returns>The Stream for the body.</returns>
        public Stream Send()
        {
            Debug.Assert(_stream == null);

            if (ChunkedTransferEncoding)
            {
                _stream = new HTTPOutputStream(_session);
                Write(_stream);
                _stream = new ChunkedStream(_session);
            }
            else if (ContentLength != UNKNOWN_CONTENT_LENGTH)
            {
                CountingOutputStream co = new CountingOutputStream();
                Write(co);
                _stream = new HTTPFixedLengthOutputStream(_session, ContentLength + co.Length);
                Write(_stream);
            }
            else
            {
                KeepAlive = false;
                _stream = new HTTPOutputStream(_session);
                Write(_stream);
            }

            return _stream;
        }