// non-javadoc, see interface HttpResponse public virtual void SetStatusLine(StatusLine statusline) { this.statusline = Args.NotNull(statusline, "Status line"); this.ver = statusline.GetProtocolVersion(); this.code = statusline.GetStatusCode(); this.reasonPhrase = statusline.GetReasonPhrase(); }
/// <summary>Creates a response from a status line.</summary> /// <remarks> /// Creates a response from a status line. /// The response will not have a reason phrase catalog and /// use the system default locale. /// </remarks> /// <param name="statusline">the status line</param> public BasicHttpResponse(StatusLine statusline) : base() { this.statusline = Args.NotNull(statusline, "Status line"); this.ver = statusline.GetProtocolVersion(); this.code = statusline.GetStatusCode(); this.reasonPhrase = statusline.GetReasonPhrase(); this.reasonCatalog = null; this.locale = null; }
/// <summary>Creates a new response.</summary> /// <remarks> /// Creates a new response. /// This is the constructor to which all others map. /// </remarks> /// <param name="statusline">the status line</param> /// <param name="catalog"> /// the reason phrase catalog, or /// <code>null</code> to disable automatic /// reason phrase lookup /// </param> /// <param name="locale"> /// the locale for looking up reason phrases, or /// <code>null</code> for the system locale /// </param> public BasicHttpResponse(StatusLine statusline, ReasonPhraseCatalog catalog, CultureInfo locale) : base() { this.statusline = Args.NotNull(statusline, "Status line"); this.ver = statusline.GetProtocolVersion(); this.code = statusline.GetStatusCode(); this.reasonPhrase = statusline.GetReasonPhrase(); this.reasonCatalog = catalog; this.locale = locale; }
/// <summary>Actually formats a status line.</summary> /// <remarks> /// Actually formats a status line. /// Called from /// <see cref="FormatStatusLine(Org.Apache.Http.StatusLine, LineFormatter)">FormatStatusLine(Org.Apache.Http.StatusLine, LineFormatter) /// </see> /// . /// </remarks> /// <param name="buffer"> /// the empty buffer into which to format, /// never <code>null</code> /// </param> /// <param name="statline">the status line to format, never <code>null</code></param> protected internal virtual void DoFormatStatusLine(CharArrayBuffer buffer, StatusLine statline) { int len = EstimateProtocolVersionLen(statline.GetProtocolVersion()) + 1 + 3 + 1; // room for "HTTP/1.1 200 " string reason = statline.GetReasonPhrase(); if (reason != null) { len += reason.Length; } buffer.EnsureCapacity(len); AppendProtocolVersion(buffer, statline.GetProtocolVersion()); buffer.Append(' '); buffer.Append(Sharpen.Extensions.ToString(statline.GetStatusCode())); buffer.Append(' '); // keep whitespace even if reason phrase is empty if (reason != null) { buffer.Append(reason); } }