コード例 #1
0
 internal HttpListenerContext(HttpConnection connection)
 {
     _connection = connection;
       _errorStatus = 400;
       _request = new HttpListenerRequest (this);
       _response = new HttpListenerResponse (this);
 }
コード例 #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 ();
        }
コード例 #3
0
 internal HttpRequestEventArgs(HttpListenerContext context)
 {
     _request = context.Request;
       _response = context.Response;
 }
コード例 #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;
        }
コード例 #5
0
        /// <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;
        }