(t *testing.T)
| 1530 | } |
| 1531 | |
| 1532 | func TestRequestHeaderProxyWithCookie(t *testing.T) { |
| 1533 | t.Parallel() |
| 1534 | |
| 1535 | // Proxy request header (read it, then write it without touching any headers). |
| 1536 | var h RequestHeader |
| 1537 | r := bytes.NewBufferString("GET /foo HTTP/1.1\r\nFoo: bar\r\nHost: aaa.com\r\nCookie: foo=bar; bazzz=aaaaaaa; x=y\r\nCookie: aqqqqq=123\r\n\r\n") |
| 1538 | br := bufio.NewReader(r) |
| 1539 | if err := h.Read(br); err != nil { |
| 1540 | t.Fatalf("unexpected error: %v", err) |
| 1541 | } |
| 1542 | w := &bytes.Buffer{} |
| 1543 | bw := bufio.NewWriter(w) |
| 1544 | if err := h.Write(bw); err != nil { |
| 1545 | t.Fatalf("unexpected error: %v", err) |
| 1546 | } |
| 1547 | if err := bw.Flush(); err != nil { |
| 1548 | t.Fatalf("unexpected error: %v", err) |
| 1549 | } |
| 1550 | |
| 1551 | var h1 RequestHeader |
| 1552 | br.Reset(w) |
| 1553 | if err := h1.Read(br); err != nil { |
| 1554 | t.Fatalf("unexpected error: %v", err) |
| 1555 | } |
| 1556 | if string(h1.RequestURI()) != "/foo" { |
| 1557 | t.Fatalf("unexpected requestURI: %q. Expecting %q", h1.RequestURI(), "/foo") |
| 1558 | } |
| 1559 | if string(h1.Host()) != "aaa.com" { |
| 1560 | t.Fatalf("unexpected host: %q. Expecting %q", h1.Host(), "aaa.com") |
| 1561 | } |
| 1562 | if string(h1.Peek("Foo")) != "bar" { |
| 1563 | t.Fatalf("unexpected Foo: %q. Expecting %q", h1.Peek("Foo"), "bar") |
| 1564 | } |
| 1565 | if string(h1.Cookie("foo")) != "bar" { |
| 1566 | t.Fatalf("unexpected cookie foo=%q. Expecting %q", h1.Cookie("foo"), "bar") |
| 1567 | } |
| 1568 | if string(h1.Cookie("bazzz")) != "aaaaaaa" { |
| 1569 | t.Fatalf("unexpected cookie bazzz=%q. Expecting %q", h1.Cookie("bazzz"), "aaaaaaa") |
| 1570 | } |
| 1571 | if string(h1.Cookie("x")) != "y" { |
| 1572 | t.Fatalf("unexpected cookie x=%q. Expecting %q", h1.Cookie("x"), "y") |
| 1573 | } |
| 1574 | if string(h1.Cookie("aqqqqq")) != "123" { |
| 1575 | t.Fatalf("unexpected cookie aqqqqq=%q. Expecting %q", h1.Cookie("aqqqqq"), "123") |
| 1576 | } |
| 1577 | } |
| 1578 | |
| 1579 | func TestResponseHeaderFirstByteReadEOF(t *testing.T) { |
| 1580 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…