fix: preserve web device session headers

This commit is contained in:
Yoilun
2026-05-15 03:08:57 +08:00
parent 1114ee00c1
commit bd49486304
2 changed files with 39 additions and 11 deletions

View File

@@ -135,6 +135,8 @@ func TestSanitizeProxyRequestHeaderDropsLoginCookie(t *testing.T) {
source.Set("User-Agent", "browser")
source.Set("Cookie", "SID=1")
source.Set("Referer", "http://10.8.0.18:13000/proxy/web/192.168.0.108/")
source.Set("Sessiontag", "abc123")
source.Set("If-Modified-Since", "0")
source.Set("X-Forwarded-For", "10.8.0.1")
loginHeader := sanitizeProxyRequestHeader(source, "/doc/page/login.asp")
@@ -147,9 +149,18 @@ func TestSanitizeProxyRequestHeaderDropsLoginCookie(t *testing.T) {
if got := loginHeader.Get("X-Forwarded-For"); got != "" {
t.Fatalf("login X-Forwarded-For = %q, want empty", got)
}
if got := loginHeader.Get("Sessiontag"); got != "abc123" {
t.Fatalf("login Sessiontag = %q, want abc123", got)
}
apiHeader := sanitizeProxyRequestHeader(source, "/ISAPI/Security/userCheck")
if got := apiHeader.Get("Cookie"); got != "SID=1" {
t.Fatalf("api Cookie = %q, want SID=1", got)
}
if got := apiHeader.Get("Sessiontag"); got != "abc123" {
t.Fatalf("api Sessiontag = %q, want abc123", got)
}
if got := apiHeader.Get("If-Modified-Since"); got != "0" {
t.Fatalf("api If-Modified-Since = %q, want 0", got)
}
}