示例#1
0
        public static void WriteHttpTrace(this StringBuilder stringBuilder, HttpMessageHeader messageHeader)
        {
            if (messageHeader == null)
            {
                return;
            }

            stringBuilder
                .AppendFormat("StartLine: {0}", messageHeader.StartLine)
                .AppendLine();

            var headers = messageHeader.Headers.Lines.ToList();

            if (headers.Count == 0)
            {
                return;
            }

            stringBuilder.AppendLine("Headers:");

            foreach (var header in headers)
            {
                stringBuilder
                    .AppendFormat("    {0}", header)
                    .AppendLine();
            }
        }
示例#2
0
        public static String GetHttpTrace(HttpMessageHeader header)
        {
            if (header == null)
            {
                return String.Empty;
            }

            var sb = new StringBuilder();

            WriteHttpTrace(sb, header);

            return sb.ToString();
        }
示例#3
0
 protected override void WriteBody(HttpMessageHeader header, Stream body, Int64 bodyLength)
 {
     if (!IsRedirect(header as HttpResponseHeader))
     {
         base.WriteBody(header, body, bodyLength);
     }
     else
     {
         if (Logger.IsDebugEnabled)
         {
             Logger.Debug("Skipping redirect response body");
         }
     }
 }
示例#4
0
 public HttpResponseHeader(HttpMessageHeader header) : base(header.StartLine, header.Headers)
 {
     StartLine = base.StartLine;
 }
示例#5
0
 public HttpResponseHeader(HttpMessageHeader header)
     : base(header.StartLine, header.Headers)
 {
     StartLine = base.StartLine;
 }
示例#6
0
 /// <summary>
 ///     Convert generic <see cref="HttpMessageHeader"/> to <see cref="HttpResponseHeader"/>
 /// </summary>
 /// <param name="header">generic HTTP header</param>
 /// <returns>HTTP request message header</returns>
 public HttpRequestHeader(HttpMessageHeader header) : base(header.StartLine, header.Headers)
 {
     StartLine = header.StartLine;
 }
 public MessageWriterTestCaseBuilder(HttpMessageHeader header, String body)
 {
     _messageBody = body;
     _httpMessageHeader = header;
 }
        public String ShouldWriteHttpMessage(HttpMessageHeader header, Stream body, long? bodyLength)
        {
            var outputStream = new MemoryStream();

            var httpWriter = new HttpMessageWriter(outputStream);

            httpWriter.Write(header, body, bodyLength);

            return Encoding.ASCII.GetString(outputStream.ToArray());
        }