public override string ToString() { bool existsContent = Content.Length > 0; var sb = new StringBuilder(); sb.Append( $"{GlobalConstants.HttpOneProtocolFragment} {_statusCodeLine}{GlobalConstants.HttpNewLine}") .Append(Headers.ToString()); if (Cookies.HasCookies()) { foreach (var httpCookie in Cookies) { sb.Append($"{GlobalConstants.SetCookie}{httpCookie}{GlobalConstants.HttpNewLine}"); } } if (existsContent) { sb.Append($"{GlobalConstants.ContentLength}{Content.Length}{GlobalConstants.HttpNewLine}"); } sb.Append($"{GlobalConstants.HttpNewLine}{GlobalConstants.HttpNewLine}"); var response = sb.ToString(); return(response); }
public override string ToString() { string httpProtocol = GlobalConstants.HttpOneProtocolFragment; int statusCode = (int)StatusCode; string statusCodeMessage = StatusCode.ToString(); StringBuilder sb = new StringBuilder(); sb.AppendLine($"{httpProtocol} {statusCode} {statusCodeMessage}").AppendLine(Headers.ToString()); if (Cookies.HasCookies()) { sb.AppendLine(Cookies.ToStringSet()); } sb.AppendLine(); return(sb.ToString()); }
public override string ToString() { StringBuilder result = new StringBuilder(); result.Append($"{GlobalConstants.HttpOneProtocolFragment} {StatusCode.GetResponseLine()}").Append(GlobalConstants.HttpNewLine).Append(Headers).Append(GlobalConstants.HttpNewLine); if (Cookies.HasCookies()) { foreach (HttpCookie httpCookie in Cookies) { result.Append($"Set-Cookie: {httpCookie}").Append(GlobalConstants.HttpNewLine); } } result.Append(GlobalConstants.HttpNewLine); return(result.ToString()); }
public override string ToString() { StringBuilder result = new StringBuilder(); result.AppendLine($"{GlobalConstants.HttpOneProtocolFragment} {StatusCode.GetResponseLine()}") .AppendLine(Headers.ToString()); if (Cookies.HasCookies()) { foreach (HttpCookie cookie in Cookies) { result.AppendLine($"{GlobalConstants.HttpResponseCookieHeaderName}: {cookie}"); } } result.AppendLine(); return(result.ToString()); }