Skip to content

Commit

Permalink
优化HttpServer请求处理埋点,只有特定内容类型才写入数据标签
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Jun 9, 2022
1 parent c92c995 commit 4a18fce
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion NewLife.Core/Http/HttpSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public class HttpSession : NetSession
"traceparent", "Authorization", "Cookie"
};

/// <summary>支持作为标签数据的内容类型</summary>
public static String[] TagTypes { get; set; } = new[] {
"text/plain", "text/xml", "application/json", "application/xml", "application/x-www-form-urlencoded"
};

private WebSocket _websocket;
private MemoryStream _cache;
#endregion
Expand Down Expand Up @@ -144,7 +149,10 @@ protected virtual HttpResponse ProcessRequest(HttpRequest request, ReceivedEvent
{
var tag = $"{Remote.EndPoint} {request.Method} {request.Url.OriginalString}";

if (request.BodyLength > 0 && request.Body != null && request.Body.Total < 8 * 1024)
if (request.BodyLength > 0 &&
request.Body != null &&
request.Body.Total < 8 * 1024 &&
request.ContentType.EqualIgnoreCase(TagTypes))
{
tag += "\r\n" + request.Body.ToStr(null, 0, 1024);
}
Expand Down

0 comments on commit 4a18fce

Please sign in to comment.