2021-02-02 12:05:47 +01:00
|
|
|
package httptransport_test
|
|
|
|
|
|
|
|
import (
|
2021-06-15 11:57:40 +02:00
|
|
|
"context"
|
2021-02-02 12:05:47 +01:00
|
|
|
"errors"
|
2021-06-15 14:01:45 +02:00
|
|
|
"io"
|
2021-02-02 12:05:47 +01:00
|
|
|
"net/http"
|
fix(netxlite): do not mutate outgoing requests (#508)
I have recently seen a data race related our way of
mutating the outgoing request to set the host header.
Unfortunately, I've lost track of the race output,
because I rebooted my Linux box before saving it.
Though, after inspecting why and and where we're mutating
outgoing requets, I've found that:
1. we add the host header when logging to have it logged,
which is not a big deal since we already emit the URL
rather than just the URL path when logging a request, and
so we can safely zap this piece of code;
2. as a result, in measurements we may omit the host header
but again this is pretty much obvious from the URL itself
and so it should not be very important (nonetheless,
avoid surprises and keep the existing behavior);
3. when the User-Agent header is not set, we default to
a `miniooni/0.1.0-dev` user agent, which is probably not
very useful anyway, so we can actually remove it.
Part of https://github.com/ooni/probe/issues/1733 (this diff
has been extracted from https://github.com/ooni/probe-cli/pull/506).
2021-09-27 13:35:47 +02:00
|
|
|
"net/url"
|
2021-02-02 12:05:47 +01:00
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/ooni/probe-cli/v3/internal/engine/netx/httptransport"
|
|
|
|
"github.com/ooni/probe-cli/v3/internal/engine/netx/trace"
|
2021-09-28 12:42:01 +02:00
|
|
|
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
2021-02-02 12:05:47 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestSaverPerformanceNoMultipleEvents(t *testing.T) {
|
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("skip test in short mode")
|
|
|
|
}
|
|
|
|
saver := &trace.Saver{}
|
|
|
|
// register twice - do we see events twice?
|
|
|
|
txp := httptransport.SaverPerformanceHTTPTransport{
|
2022-01-07 18:33:37 +01:00
|
|
|
HTTPTransport: http.DefaultTransport.(*http.Transport),
|
|
|
|
Saver: saver,
|
2021-02-02 12:05:47 +01:00
|
|
|
}
|
|
|
|
txp = httptransport.SaverPerformanceHTTPTransport{
|
2022-01-07 18:33:37 +01:00
|
|
|
HTTPTransport: txp,
|
|
|
|
Saver: saver,
|
2021-02-02 12:05:47 +01:00
|
|
|
}
|
|
|
|
req, err := http.NewRequest("GET", "https://www.google.com", nil)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
resp, err := txp.RoundTrip(req)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal("not the error we expected")
|
|
|
|
}
|
|
|
|
if resp == nil {
|
|
|
|
t.Fatal("expected non nil response here")
|
|
|
|
}
|
|
|
|
ev := saver.Read()
|
|
|
|
// we should specifically see the events not attached to any
|
|
|
|
// context being submitted twice. This is fine because they are
|
|
|
|
// explicit, while the context is implicit and hence leads to
|
|
|
|
// more subtle bugs. For example, this happens when you measure
|
|
|
|
// every event and combine HTTP with DoH.
|
|
|
|
if len(ev) != 3 {
|
|
|
|
t.Fatal("expected three events")
|
|
|
|
}
|
|
|
|
expected := []string{
|
|
|
|
"http_wrote_headers", // measured with context
|
|
|
|
"http_wrote_request", // measured with context
|
|
|
|
"http_first_response_byte", // measured with context
|
|
|
|
}
|
|
|
|
for i := 0; i < len(expected); i++ {
|
|
|
|
if ev[i].Name != expected[i] {
|
|
|
|
t.Fatal("unexpected event name")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSaverMetadataSuccess(t *testing.T) {
|
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("skip test in short mode")
|
|
|
|
}
|
|
|
|
saver := &trace.Saver{}
|
|
|
|
txp := httptransport.SaverMetadataHTTPTransport{
|
2022-01-07 18:33:37 +01:00
|
|
|
HTTPTransport: http.DefaultTransport.(*http.Transport),
|
|
|
|
Saver: saver,
|
2021-02-02 12:05:47 +01:00
|
|
|
}
|
|
|
|
req, err := http.NewRequest("GET", "https://www.google.com", nil)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
req.Header.Add("User-Agent", "miniooni/0.1.0-dev")
|
|
|
|
resp, err := txp.RoundTrip(req)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal("not the error we expected")
|
|
|
|
}
|
|
|
|
if resp == nil {
|
|
|
|
t.Fatal("expected non nil response here")
|
|
|
|
}
|
|
|
|
ev := saver.Read()
|
|
|
|
if len(ev) != 2 {
|
|
|
|
t.Fatal("expected two events")
|
|
|
|
}
|
|
|
|
//
|
|
|
|
if ev[0].HTTPMethod != "GET" {
|
|
|
|
t.Fatal("unexpected Method")
|
|
|
|
}
|
|
|
|
if len(ev[0].HTTPHeaders) <= 0 {
|
|
|
|
t.Fatal("unexpected Headers")
|
|
|
|
}
|
|
|
|
if ev[0].HTTPURL != "https://www.google.com" {
|
|
|
|
t.Fatal("unexpected URL")
|
|
|
|
}
|
|
|
|
if ev[0].Name != "http_request_metadata" {
|
|
|
|
t.Fatal("unexpected Name")
|
|
|
|
}
|
|
|
|
if !ev[0].Time.Before(time.Now()) {
|
|
|
|
t.Fatal("unexpected Time")
|
|
|
|
}
|
|
|
|
//
|
|
|
|
if ev[1].HTTPStatusCode != 200 {
|
|
|
|
t.Fatal("unexpected StatusCode")
|
|
|
|
}
|
|
|
|
if len(ev[1].HTTPHeaders) <= 0 {
|
|
|
|
t.Fatal("unexpected Headers")
|
|
|
|
}
|
|
|
|
if ev[1].Name != "http_response_metadata" {
|
|
|
|
t.Fatal("unexpected Name")
|
|
|
|
}
|
|
|
|
if !ev[1].Time.After(ev[0].Time) {
|
|
|
|
t.Fatal("unexpected Time")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSaverMetadataFailure(t *testing.T) {
|
|
|
|
expected := errors.New("mocked error")
|
|
|
|
saver := &trace.Saver{}
|
|
|
|
txp := httptransport.SaverMetadataHTTPTransport{
|
2022-01-07 18:33:37 +01:00
|
|
|
HTTPTransport: httptransport.FakeTransport{
|
2021-02-02 12:05:47 +01:00
|
|
|
Err: expected,
|
|
|
|
},
|
|
|
|
Saver: saver,
|
|
|
|
}
|
|
|
|
req, err := http.NewRequest("GET", "http://www.google.com", nil)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
req.Header.Add("User-Agent", "miniooni/0.1.0-dev")
|
|
|
|
resp, err := txp.RoundTrip(req)
|
|
|
|
if !errors.Is(err, expected) {
|
|
|
|
t.Fatal("not the error we expected")
|
|
|
|
}
|
|
|
|
if resp != nil {
|
|
|
|
t.Fatal("expected nil response here")
|
|
|
|
}
|
|
|
|
ev := saver.Read()
|
|
|
|
if len(ev) != 1 {
|
|
|
|
t.Fatal("expected one event")
|
|
|
|
}
|
|
|
|
if ev[0].HTTPMethod != "GET" {
|
|
|
|
t.Fatal("unexpected Method")
|
|
|
|
}
|
|
|
|
if len(ev[0].HTTPHeaders) <= 0 {
|
|
|
|
t.Fatal("unexpected Headers")
|
|
|
|
}
|
|
|
|
if ev[0].HTTPURL != "http://www.google.com" {
|
|
|
|
t.Fatal("unexpected URL")
|
|
|
|
}
|
|
|
|
if ev[0].Name != "http_request_metadata" {
|
|
|
|
t.Fatal("unexpected Name")
|
|
|
|
}
|
|
|
|
if !ev[0].Time.Before(time.Now()) {
|
|
|
|
t.Fatal("unexpected Time")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSaverTransactionSuccess(t *testing.T) {
|
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("skip test in short mode")
|
|
|
|
}
|
|
|
|
saver := &trace.Saver{}
|
|
|
|
txp := httptransport.SaverTransactionHTTPTransport{
|
2022-01-07 18:33:37 +01:00
|
|
|
HTTPTransport: http.DefaultTransport.(*http.Transport),
|
|
|
|
Saver: saver,
|
2021-02-02 12:05:47 +01:00
|
|
|
}
|
|
|
|
req, err := http.NewRequest("GET", "https://www.google.com", nil)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
resp, err := txp.RoundTrip(req)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal("not the error we expected")
|
|
|
|
}
|
|
|
|
if resp == nil {
|
|
|
|
t.Fatal("expected non nil response here")
|
|
|
|
}
|
|
|
|
ev := saver.Read()
|
|
|
|
if len(ev) != 2 {
|
|
|
|
t.Fatal("expected two events")
|
|
|
|
}
|
|
|
|
//
|
|
|
|
if ev[0].Name != "http_transaction_start" {
|
|
|
|
t.Fatal("unexpected Name")
|
|
|
|
}
|
|
|
|
if !ev[0].Time.Before(time.Now()) {
|
|
|
|
t.Fatal("unexpected Time")
|
|
|
|
}
|
|
|
|
//
|
|
|
|
if ev[1].Err != nil {
|
|
|
|
t.Fatal("unexpected Err")
|
|
|
|
}
|
|
|
|
if ev[1].Name != "http_transaction_done" {
|
|
|
|
t.Fatal("unexpected Name")
|
|
|
|
}
|
|
|
|
if !ev[1].Time.After(ev[0].Time) {
|
|
|
|
t.Fatal("unexpected Time")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSaverTransactionFailure(t *testing.T) {
|
|
|
|
expected := errors.New("mocked error")
|
|
|
|
saver := &trace.Saver{}
|
|
|
|
txp := httptransport.SaverTransactionHTTPTransport{
|
2022-01-07 18:33:37 +01:00
|
|
|
HTTPTransport: httptransport.FakeTransport{
|
2021-02-02 12:05:47 +01:00
|
|
|
Err: expected,
|
|
|
|
},
|
|
|
|
Saver: saver,
|
|
|
|
}
|
|
|
|
req, err := http.NewRequest("GET", "http://www.google.com", nil)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
resp, err := txp.RoundTrip(req)
|
|
|
|
if !errors.Is(err, expected) {
|
|
|
|
t.Fatal("not the error we expected")
|
|
|
|
}
|
|
|
|
if resp != nil {
|
|
|
|
t.Fatal("expected nil response here")
|
|
|
|
}
|
|
|
|
ev := saver.Read()
|
|
|
|
if len(ev) != 2 {
|
|
|
|
t.Fatal("expected two events")
|
|
|
|
}
|
|
|
|
if ev[0].Name != "http_transaction_start" {
|
|
|
|
t.Fatal("unexpected Name")
|
|
|
|
}
|
|
|
|
if !ev[0].Time.Before(time.Now()) {
|
|
|
|
t.Fatal("unexpected Time")
|
|
|
|
}
|
|
|
|
if ev[1].Name != "http_transaction_done" {
|
|
|
|
t.Fatal("unexpected Name")
|
|
|
|
}
|
|
|
|
if !errors.Is(ev[1].Err, expected) {
|
|
|
|
t.Fatal("unexpected Err")
|
|
|
|
}
|
|
|
|
if !ev[1].Time.After(ev[0].Time) {
|
|
|
|
t.Fatal("unexpected Time")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSaverBodySuccess(t *testing.T) {
|
|
|
|
saver := new(trace.Saver)
|
|
|
|
txp := httptransport.SaverBodyHTTPTransport{
|
2022-01-07 18:33:37 +01:00
|
|
|
HTTPTransport: httptransport.FakeTransport{
|
2021-02-02 12:05:47 +01:00
|
|
|
Func: func(req *http.Request) (*http.Response, error) {
|
2021-09-28 12:42:01 +02:00
|
|
|
data, err := netxlite.ReadAllContext(context.Background(), req.Body)
|
2021-02-02 12:05:47 +01:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if string(data) != "deadbeef" {
|
|
|
|
t.Fatal("invalid data")
|
|
|
|
}
|
|
|
|
return &http.Response{
|
|
|
|
StatusCode: 501,
|
2021-06-15 14:01:45 +02:00
|
|
|
Body: io.NopCloser(strings.NewReader("abad1dea")),
|
2021-02-02 12:05:47 +01:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
},
|
|
|
|
SnapshotSize: 4,
|
|
|
|
Saver: saver,
|
|
|
|
}
|
|
|
|
body := strings.NewReader("deadbeef")
|
|
|
|
req, err := http.NewRequest("POST", "http://x.org/y", body)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
resp, err := txp.RoundTrip(req)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if resp.StatusCode != 501 {
|
|
|
|
t.Fatal("unexpected status code")
|
|
|
|
}
|
|
|
|
defer resp.Body.Close()
|
2021-09-28 12:42:01 +02:00
|
|
|
data, err := netxlite.ReadAllContext(context.Background(), resp.Body)
|
2021-02-02 12:05:47 +01:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if string(data) != "abad1dea" {
|
|
|
|
t.Fatal("unexpected body")
|
|
|
|
}
|
|
|
|
ev := saver.Read()
|
|
|
|
if len(ev) != 2 {
|
|
|
|
t.Fatal("unexpected number of events")
|
|
|
|
}
|
|
|
|
if string(ev[0].Data) != "dead" {
|
|
|
|
t.Fatal("invalid Data")
|
|
|
|
}
|
|
|
|
if ev[0].DataIsTruncated != true {
|
|
|
|
t.Fatal("invalid DataIsTruncated")
|
|
|
|
}
|
|
|
|
if ev[0].Name != "http_request_body_snapshot" {
|
|
|
|
t.Fatal("invalid Name")
|
|
|
|
}
|
|
|
|
if ev[0].Time.After(time.Now()) {
|
|
|
|
t.Fatal("invalid Time")
|
|
|
|
}
|
|
|
|
if string(ev[1].Data) != "abad" {
|
|
|
|
t.Fatal("invalid Data")
|
|
|
|
}
|
|
|
|
if ev[1].DataIsTruncated != true {
|
|
|
|
t.Fatal("invalid DataIsTruncated")
|
|
|
|
}
|
|
|
|
if ev[1].Name != "http_response_body_snapshot" {
|
|
|
|
t.Fatal("invalid Name")
|
|
|
|
}
|
|
|
|
if ev[1].Time.Before(ev[0].Time) {
|
|
|
|
t.Fatal("invalid Time")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSaverBodyRequestReadError(t *testing.T) {
|
|
|
|
saver := new(trace.Saver)
|
|
|
|
txp := httptransport.SaverBodyHTTPTransport{
|
2022-01-07 18:33:37 +01:00
|
|
|
HTTPTransport: httptransport.FakeTransport{
|
2021-02-02 12:05:47 +01:00
|
|
|
Func: func(req *http.Request) (*http.Response, error) {
|
|
|
|
panic("should not be called")
|
|
|
|
},
|
|
|
|
},
|
|
|
|
SnapshotSize: 4,
|
|
|
|
Saver: saver,
|
|
|
|
}
|
|
|
|
expected := errors.New("mocked error")
|
|
|
|
body := httptransport.FakeBody{Err: expected}
|
|
|
|
req, err := http.NewRequest("POST", "http://x.org/y", body)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
resp, err := txp.RoundTrip(req)
|
|
|
|
if !errors.Is(err, expected) {
|
|
|
|
t.Fatal("not the error we expected")
|
|
|
|
}
|
|
|
|
if resp != nil {
|
|
|
|
t.Fatal("expected nil response")
|
|
|
|
}
|
|
|
|
ev := saver.Read()
|
|
|
|
if len(ev) != 0 {
|
|
|
|
t.Fatal("unexpected number of events")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSaverBodyRoundTripError(t *testing.T) {
|
|
|
|
saver := new(trace.Saver)
|
|
|
|
expected := errors.New("mocked error")
|
|
|
|
txp := httptransport.SaverBodyHTTPTransport{
|
2022-01-07 18:33:37 +01:00
|
|
|
HTTPTransport: httptransport.FakeTransport{
|
2021-02-02 12:05:47 +01:00
|
|
|
Err: expected,
|
|
|
|
},
|
|
|
|
SnapshotSize: 4,
|
|
|
|
Saver: saver,
|
|
|
|
}
|
|
|
|
body := strings.NewReader("deadbeef")
|
|
|
|
req, err := http.NewRequest("POST", "http://x.org/y", body)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
resp, err := txp.RoundTrip(req)
|
|
|
|
if !errors.Is(err, expected) {
|
|
|
|
t.Fatal("not the error we expected")
|
|
|
|
}
|
|
|
|
if resp != nil {
|
|
|
|
t.Fatal("expected nil response")
|
|
|
|
}
|
|
|
|
ev := saver.Read()
|
|
|
|
if len(ev) != 1 {
|
|
|
|
t.Fatal("unexpected number of events")
|
|
|
|
}
|
|
|
|
if string(ev[0].Data) != "dead" {
|
|
|
|
t.Fatal("invalid Data")
|
|
|
|
}
|
|
|
|
if ev[0].DataIsTruncated != true {
|
|
|
|
t.Fatal("invalid DataIsTruncated")
|
|
|
|
}
|
|
|
|
if ev[0].Name != "http_request_body_snapshot" {
|
|
|
|
t.Fatal("invalid Name")
|
|
|
|
}
|
|
|
|
if ev[0].Time.After(time.Now()) {
|
|
|
|
t.Fatal("invalid Time")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSaverBodyResponseReadError(t *testing.T) {
|
|
|
|
saver := new(trace.Saver)
|
|
|
|
expected := errors.New("mocked error")
|
|
|
|
txp := httptransport.SaverBodyHTTPTransport{
|
2022-01-07 18:33:37 +01:00
|
|
|
HTTPTransport: httptransport.FakeTransport{
|
2021-02-02 12:05:47 +01:00
|
|
|
Func: func(req *http.Request) (*http.Response, error) {
|
|
|
|
return &http.Response{
|
|
|
|
StatusCode: 200,
|
|
|
|
Body: httptransport.FakeBody{
|
|
|
|
Err: expected,
|
|
|
|
},
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
},
|
|
|
|
SnapshotSize: 4,
|
|
|
|
Saver: saver,
|
|
|
|
}
|
|
|
|
body := strings.NewReader("deadbeef")
|
|
|
|
req, err := http.NewRequest("POST", "http://x.org/y", body)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
resp, err := txp.RoundTrip(req)
|
|
|
|
if !errors.Is(err, expected) {
|
|
|
|
t.Fatal("not the error we expected")
|
|
|
|
}
|
|
|
|
if resp != nil {
|
|
|
|
t.Fatal("expected nil response")
|
|
|
|
}
|
|
|
|
ev := saver.Read()
|
|
|
|
if len(ev) != 1 {
|
|
|
|
t.Fatal("unexpected number of events")
|
|
|
|
}
|
|
|
|
if string(ev[0].Data) != "dead" {
|
|
|
|
t.Fatal("invalid Data")
|
|
|
|
}
|
|
|
|
if ev[0].DataIsTruncated != true {
|
|
|
|
t.Fatal("invalid DataIsTruncated")
|
|
|
|
}
|
|
|
|
if ev[0].Name != "http_request_body_snapshot" {
|
|
|
|
t.Fatal("invalid Name")
|
|
|
|
}
|
|
|
|
if ev[0].Time.After(time.Now()) {
|
|
|
|
t.Fatal("invalid Time")
|
|
|
|
}
|
|
|
|
}
|
fix(netxlite): do not mutate outgoing requests (#508)
I have recently seen a data race related our way of
mutating the outgoing request to set the host header.
Unfortunately, I've lost track of the race output,
because I rebooted my Linux box before saving it.
Though, after inspecting why and and where we're mutating
outgoing requets, I've found that:
1. we add the host header when logging to have it logged,
which is not a big deal since we already emit the URL
rather than just the URL path when logging a request, and
so we can safely zap this piece of code;
2. as a result, in measurements we may omit the host header
but again this is pretty much obvious from the URL itself
and so it should not be very important (nonetheless,
avoid surprises and keep the existing behavior);
3. when the User-Agent header is not set, we default to
a `miniooni/0.1.0-dev` user agent, which is probably not
very useful anyway, so we can actually remove it.
Part of https://github.com/ooni/probe/issues/1733 (this diff
has been extracted from https://github.com/ooni/probe-cli/pull/506).
2021-09-27 13:35:47 +02:00
|
|
|
|
|
|
|
func TestCloneHeaders(t *testing.T) {
|
|
|
|
t.Run("with req.Host set", func(t *testing.T) {
|
|
|
|
req := &http.Request{
|
|
|
|
Host: "www.example.com",
|
|
|
|
URL: &url.URL{
|
|
|
|
Host: "www.kernel.org",
|
|
|
|
},
|
|
|
|
Header: http.Header{},
|
|
|
|
}
|
|
|
|
txp := httptransport.SaverMetadataHTTPTransport{}
|
|
|
|
header := txp.CloneHeaders(req)
|
|
|
|
if header.Get("Host") != "www.example.com" {
|
|
|
|
t.Fatal("did not set Host header correctly")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("with only req.URL.Host set", func(t *testing.T) {
|
|
|
|
req := &http.Request{
|
|
|
|
Host: "",
|
|
|
|
URL: &url.URL{
|
|
|
|
Host: "www.kernel.org",
|
|
|
|
},
|
|
|
|
Header: http.Header{},
|
|
|
|
}
|
|
|
|
txp := httptransport.SaverMetadataHTTPTransport{}
|
|
|
|
header := txp.CloneHeaders(req)
|
|
|
|
if header.Get("Host") != "www.kernel.org" {
|
|
|
|
t.Fatal("did not set Host header correctly")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|