Пример #1
0
        private void Init()
        {
#if SSL
            if (ssl_stream != null)
            {
                ssl_stream.AuthenticateAsServer(cert, true, (SslProtocols)ServicePointManager.SecurityProtocol, false);
            }
#endif
            _contextBound = false;
            _iStream      = null;
            _oStream      = null;
            Prefix        = null;
            _ms           = new MemoryStream();
            _position     = 0;
            _inputState   = InputState.RequestLine;
            _lineState    = LineState.None;
            _context      = new HttpListenerContext(this);
        }
Пример #2
0
        public RequestStream GetRequestStream(bool chunked, long contentlength)
        {
            if (_iStream != null)
            {
                return(_iStream);
            }

            var buffer = _ms.GetBuffer();
            var length = (int)_ms.Length;

            _ms = null;
            if (chunked)
            {
                _chunked = true;
                _context.Response.SendChunked = true;
                _iStream = new ChunkedInputStream(_context, _stream, buffer, _position, length - _position);
            }
            else
            {
                _iStream = new RequestStream(_stream, buffer, _position, length - _position, contentlength);
            }
            return(_iStream);
        }