internal static StringBuilder GetRawContentHeader(WebResponse baseResponse)
        {
            StringBuilder raw = new StringBuilder();

            // add protocol and status line
            string protocol = WebResponseHelper.GetProtocol(baseResponse);

            if (!String.IsNullOrEmpty(protocol))
            {
                int    statusCode        = WebResponseHelper.GetStatusCode(baseResponse);
                string statusDescription = WebResponseHelper.GetStatusDescription(baseResponse);
                raw.AppendFormat("{0} {1} {2}", protocol, statusCode, statusDescription);
                raw.AppendLine();
            }

            // add headers
            foreach (string key in baseResponse.Headers.AllKeys)
            {
                string value = baseResponse.Headers[key];
                raw.AppendFormat("{0}: {1}", key, value);
                raw.AppendLine();
            }

            raw.AppendLine();
            return(raw);
        }
Exemple #2
0
        internal static StringBuilder GetRawContentHeader(HttpResponseMessage response)
        {
            StringBuilder raw = new StringBuilder();

            string protocol = WebResponseHelper.GetProtocol(response);

            if (!string.IsNullOrEmpty(protocol))
            {
                int    statusCode        = WebResponseHelper.GetStatusCode(response);
                string statusDescription = WebResponseHelper.GetStatusDescription(response);
                raw.AppendFormat("{0} {1} {2}", protocol, statusCode, statusDescription);
                raw.AppendLine();
            }

            HttpHeaders[] headerCollections =
            {
                response.Headers,
                response.Content == null ? null : response.Content.Headers
            };

            foreach (var headerCollection in headerCollections)
            {
                if (headerCollection == null)
                {
                    continue;
                }

                foreach (var header in headerCollection)
                {
                    // Headers may have multiple entries with different values
                    foreach (var headerValue in header.Value)
                    {
                        raw.Append(header.Key);
                        raw.Append(": ");
                        raw.Append(headerValue);
                        raw.AppendLine();
                    }
                }
            }

            raw.AppendLine();
            return(raw);
        }
Exemple #3
0
        internal static StringBuilder GetRawContentHeader(WebResponse baseResponse)
        {
            StringBuilder builder  = new StringBuilder();
            string        protocol = WebResponseHelper.GetProtocol(baseResponse);

            if (!string.IsNullOrEmpty(protocol))
            {
                int    statusCode        = WebResponseHelper.GetStatusCode(baseResponse);
                string statusDescription = WebResponseHelper.GetStatusDescription(baseResponse);
                builder.AppendFormat("{0} {1} {2}", protocol, statusCode, statusDescription);
                builder.AppendLine();
            }
            foreach (string str3 in baseResponse.Headers.AllKeys)
            {
                string str4 = baseResponse.Headers[str3];
                builder.AppendFormat("{0}: {1}", str3, str4);
                builder.AppendLine();
            }
            builder.AppendLine();
            return(builder);
        }
Exemple #4
0
        internal static StringBuilder GetRawContentHeader(HttpResponseMessage response)
        {
            StringBuilder raw = new StringBuilder();

            string protocol = WebResponseHelper.GetProtocol(response);

            if (!string.IsNullOrEmpty(protocol))
            {
                int    statusCode        = WebResponseHelper.GetStatusCode(response);
                string statusDescription = WebResponseHelper.GetStatusDescription(response);
                raw.AppendFormat("{0} {1} {2}", protocol, statusCode, statusDescription);
                raw.AppendLine();
            }

            foreach (var entry in response.Headers)
            {
                raw.AppendFormat("{0}: {1}", entry.Key, entry.Value.FirstOrDefault());
                raw.AppendLine();
            }

            raw.AppendLine();
            return(raw);
        }