internal HttpListenerContext(HttpConnection connection)
 {
     _connection = connection;
       _errorStatus = 400;
       _request = new HttpListenerRequest (this);
       _response = new HttpListenerResponse (this);
 }
Ejemplo n.º 2
0
        internal ResponseStream(
      Stream stream, HttpListenerResponse response, bool ignoreWriteExceptions)
        {
            _stream = stream;
              _response = response;

              if (ignoreWriteExceptions) {
            _write = writeWithoutThrowingException;
            _writeChunked = writeChunkedWithoutThrowingException;
              }
              else {
            _write = stream.Write;
            _writeChunked = writeChunked;
              }

              _body = new MemoryStream ();
        }
 internal HttpRequestEventArgs(HttpListenerContext context)
 {
     _request = context.Request;
       _response = context.Response;
 }
Ejemplo n.º 4
0
        internal void Close(bool force)
        {
            if (_disposed)
            return;

              _disposed = true;
              if (!force && flush (true)) {
            _response.Close ();
              }
              else {
            if (_sendChunked) {
              var last = getChunkSizeBytes (0, true);
              _write (last, 0, last.Length);
            }

            _body.Dispose ();
            _body = null;

            _response.Abort ();
              }

              _response = null;
              _stream = null;
        }
        /// <summary>
        /// Copies some properties from the specified <see cref="HttpListenerResponse"/> to
        /// this response.
        /// </summary>
        /// <param name="templateResponse">
        /// A <see cref="HttpListenerResponse"/> to copy.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="templateResponse"/> is <see langword="null"/>.
        /// </exception>
        public void CopyFrom(HttpListenerResponse templateResponse)
        {
            if (templateResponse == null)
            throw new ArgumentNullException ("templateResponse");

              if (templateResponse._headers != null) {
            if (_headers != null)
              _headers.Clear ();

            Headers.Add (templateResponse._headers);
              }
              else if (_headers != null) {
            _headers = null;
              }

              _contentLength = templateResponse._contentLength;
              _statusCode = templateResponse._statusCode;
              _statusDescription = templateResponse._statusDescription;
              _keepAlive = templateResponse._keepAlive;
              _version = templateResponse._version;
        }