test that 304 Not Modified responses are returned properly.
(t *testing.T)
| 581 | |
| 582 | // test that 304 Not Modified responses are returned properly. |
| 583 | func TestProxy_ServeHTTP_is304(t *testing.T) { |
| 584 | p := &Proxy{ |
| 585 | Client: &http.Client{ |
| 586 | Transport: &testTransport{}, |
| 587 | }, |
| 588 | } |
| 589 | |
| 590 | req, _ := http.NewRequest("GET", "http://localhost/http://good.test/etag", nil) |
| 591 | req.Header.Add("If-None-Match", `"tag"`) |
| 592 | resp := httptest.NewRecorder() |
| 593 | p.ServeHTTP(resp, req) |
| 594 | |
| 595 | if got, want := resp.Code, http.StatusNotModified; got != want { |
| 596 | t.Errorf("ServeHTTP(%v) returned status %d, want %d", req, got, want) |
| 597 | } |
| 598 | if got, want := resp.Header().Get("Etag"), `"tag"`; got != want { |
| 599 | t.Errorf("ServeHTTP(%v) returned etag header %v, want %v", req, got, want) |
| 600 | } |
| 601 | } |
| 602 | |
| 603 | func TestProxy_ServeHTTP_cached304(t *testing.T) { |
| 604 | cache := lrucache.New(1024*1024*8, 0) |