/// <summary> /// Constructs a HTTP 1.1 response. /// </summary> /// <param name="status">HTTP response status code.</param> /// <remarks> /// The reason phrase will be initialized to the standard phrase /// from HttpStack.GetReasonPhrase(). /// </remarks> public HttpResponse(HttpStatus status) : base(status, HttpStack.GetReasonPhrase(status)) { this.parseState = ParseState.Disabled; if (content == null) { content = new BlockArray(); } }
/// <summary> /// Completes an asynchronous connection attempt. /// </summary> /// <param name="ar">The async result returned by <see cref="BeginConnect(string, System.AsyncCallback, object)" />.</param> public void EndConnect(IAsyncResult ar) { using (TimedLock.Lock(this)) { sock.EndConnect(ar); this.ipAddress = ((IPEndPoint)sock.RemoteEndPoint).Address; this.timedOut = false; this.queryPending = false; HttpStack.AddConnection(this); } }
/// <summary> /// Closes the connection if open. /// </summary> public void Close() { using (TimedLock.Lock(this)) { if (sock == null || !sock.IsOpen) { return; } sock.Close(); } HttpStack.RemoveConnection(this); }
/// <summary> /// Constructor. /// </summary> /// <param name="status">The <see cref="HttpStatus" /> code.</param> public HttpException(HttpStatus status) : base(string.Format("HTTP Error [{0}={1}].", HttpStack.GetReasonPhrase(status), (int)status)) { }