private HttpApiResponse SetResponse(HttpResponseMessage response, byte[] data) { HttpApiResponse result = new HttpApiResponse((int)response.StatusCode, response.ReasonPhrase); foreach (var item in response.Headers) { if (item.Key.Equals("transfer-encoding", StringComparison.OrdinalIgnoreCase)) continue; var v = string.Join(";", item.Value); if (item.Key.StartsWith("set-cookie", StringComparison.OrdinalIgnoreCase)) { //Console.WriteLine(string.Join(";",item.Value)); v = ReplaceCookieDomain(v, ""); } result.Headers[item.Key] = v; } result.Contents = data; return result; }
public static HttpApiResponse FromText( string content, string contentType, int status = 200, string statusDescription = "Ok") { contentType = contentType ?? "text"; contentType += "; charset=utf-8"; HttpApiResponse result = new HttpApiResponse(status, statusDescription); result.ContentType = contentType; result.Contents = Encoding.UTF8.GetBytes(content); return result; }