TestForwardUncachedPreservesMethod walks every method that hits the non-GET path and checks the origin saw the same method. Ensures we don't accidentally specialise on PUT/POST and break HEAD/DELETE/etc.
(t *testing.T)
| 1362 | } |
| 1363 | |
| 1364 | // TestForwardUncachedStripsHopByHopBothDirections verifies that |
| 1365 | // hop-by-hop headers (per RFC 7230 §6.1) are NOT forwarded in either |
| 1366 | // direction. Forwarding hop-by-hop headers can confuse origin / client |
| 1367 | // parsers — Connection, Keep-Alive, TE, Trailers, Transfer-Encoding, |
| 1368 | // Upgrade, Proxy-Authorization, Proxy-Authenticate. |
| 1369 | func TestForwardUncachedStripsHopByHopBothDirections(t *testing.T) { |
| 1370 | proxy := newTestProxy(t) |
| 1371 | |
| 1372 | var originSawConnection, originSawKeepAlive string |
| 1373 | _, originURL := newTestServer(t, func(w http.ResponseWriter, r *http.Request) { |
| 1374 | originSawConnection = r.Header.Get("Connection") |
| 1375 | originSawKeepAlive = r.Header.Get("Keep-Alive") |
| 1376 | w.Header().Set("Connection", "should-not-leak") |
| 1377 | w.Header().Set("Keep-Alive", "timeout=5") |
| 1378 | w.Header().Set("X-Allowed", "yes") |
| 1379 | w.WriteHeader(http.StatusOK) |
| 1380 | }) |
| 1381 | |
| 1382 | req := httptest.NewRequest(http.MethodPut, originURL+"/b/k", bytes.NewReader([]byte("x"))) |
| 1383 | req.Host = req.URL.Host |
| 1384 | req.ContentLength = 1 |
| 1385 | req.Header.Set("Connection", "close") |
| 1386 | req.Header.Set("Keep-Alive", "timeout=5") |
nothing calls this directly
no test coverage detected