Skip to content

Commit

Permalink
HttpCodec.Write测试通过
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Nov 13, 2019
1 parent 76c427f commit b105959
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions NewLife.Core/Http/HttpCodec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,10 @@ public virtual Boolean ParseHeaders()
/// <returns></returns>
public virtual Packet ToPacket()
{
// 使用子数据区,不改变原来的头部对象
var pk = Header.Slice(0, -1);
//pk.Next = NewLine;
pk.Next = new[] { (Byte)'\r', (Byte)'\n' };
pk.Next = NewLine;
//pk.Next = new[] { (Byte)'\r', (Byte)'\n' };

var pay = Payload;
if (pay != null && pay.Total > 0) pk.Append(pay);
Expand Down
4 changes: 2 additions & 2 deletions NewLife.Core/Http/HttpEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public virtual IMessage CreateRequest(String action, Object args)
sb.AppendFormat("Content-Length:{0}\r\n", pk.Total);
sb.AppendLine("Content-Type:application/json");
}
sb.AppendLine("Connection:keep-alive");
sb.Append("Connection:keep-alive");

req.Header = sb.Put(true).GetBytes();

Expand Down Expand Up @@ -193,7 +193,7 @@ public virtual IMessage CreateResponse(IMessage msg, String action, Int32 code,

sb.AppendFormat("Content-Length:{0}\r\n", pk?.Total ?? 0);
sb.AppendLine("Content-Type:application/json");
sb.AppendLine("Connection:keep-alive");
sb.Append("Connection:keep-alive");

rs.Header = sb.Put(true).GetBytes();

Expand Down

0 comments on commit b105959

Please sign in to comment.