Files
Dwi Siswanto 50996a7481 fix(http): isolate project cache keys by scheme & host
Prev. project keyed cache lookups from dumped HTTP
request bytes alone. For eq requests, this allowed
"http" and "https" targets to collide and reuse
cached responses across schemes.

Derive a scoped cache key by prefixing normalized
scheme://host before `projectfile.{Get,Set}`
keying input in the HTTP protocol path.

Close #6866

Signed-off-by: Dwi Siswanto <git@dw1.io>
2026-03-05 13:15:17 +07:00

20 lines
559 B
Go

package http
import (
"bytes"
"testing"
"github.com/stretchr/testify/require"
)
func TestGetHTTPProjectCacheScope_SeparatesSchemeAndPort(t *testing.T) {
requestDump := []byte("GET / HTTP/1.1\r\nHost: example.com\r\n\r\n")
httpScoped := getHTTPProjectCacheScope(requestDump, "http", "example.com:80")
httpsScoped := getHTTPProjectCacheScope(requestDump, "https", "example.com:443")
require.NotEqual(t, httpScoped, httpsScoped)
require.True(t, bytes.HasSuffix(httpScoped, requestDump))
require.True(t, bytes.HasSuffix(httpsScoped, requestDump))
}