fix: add Host header to HTTP test requests for fasthttp v1.70.0 compatibility

fasthttp v1.70.0 now enforces the HTTP/1.1 requirement of exactly
one Host header, rejecting requests that omit it. Fix tests that
were failing due to missing host.
This commit is contained in:
Ben McClelland
2026-04-13 19:13:58 -07:00
parent ccba8a5736
commit 873148a5c4
6 changed files with 17 additions and 0 deletions
@@ -103,6 +103,7 @@ func makePostRequest(t *testing.T, body []byte, boundary string) *http.Request {
req, err := http.NewRequest(http.MethodPost, "/mybucket", bytes.NewReader(body))
assert.NoError(t, err)
req.Host = "localhost"
req.Header.Set("Content-Type", fmt.Sprintf("multipart/form-data; boundary=%s", boundary))
// Set both the header and the int64 field: app.Test() serialises the
// request via req.Write() which uses req.ContentLength; fasthttp then
@@ -283,6 +284,7 @@ func TestAuthorizePostObject_InvalidContentType_ReturnsError(t *testing.T) {
req, err := http.NewRequest(http.MethodPost, "/mybucket", strings.NewReader("body"))
assert.NoError(t, err)
req.Host = "localhost"
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Content-Length", "4")