go/src/net/http/client_test.go

var robotsTxtHandler

// pedanticReadAll works like io.ReadAll but additionally
// verifies that r obeys the documented io.Reader contract.
func pedanticReadAll(r io.Reader) (b []byte, err error) {}

func TestClient(t *testing.T) {}

func testClient(t *testing.T, mode testMode) {}

func TestClientHead(t *testing.T) {}

func testClientHead(t *testing.T, mode testMode) {}

type recordingTransport

func (t *recordingTransport) RoundTrip(req *Request) (resp *Response, err error) {}

func TestGetRequestFormat(t *testing.T) {}

func TestPostRequestFormat(t *testing.T) {}

func TestPostFormRequestFormat(t *testing.T) {}

func TestClientRedirects(t *testing.T) {}

func testClientRedirects(t *testing.T, mode testMode) {}

// Tests that Client redirects' contexts are derived from the original request's context.
func TestClientRedirectsContext(t *testing.T) {}

func testClientRedirectsContext(t *testing.T, mode testMode) {}

type redirectTest

func TestPostRedirects(t *testing.T) {}

func TestDeleteRedirects(t *testing.T) {}

func testRedirectsByMethod(t *testing.T, mode testMode, method string, table []redirectTest, want string) {}

func removeCommonLines(a, b string) (asuffix, bsuffix string, commonLines int) {}

func TestClientRedirectUseResponse(t *testing.T) {}

func testClientRedirectUseResponse(t *testing.T, mode testMode) {}

// Issues 17773 and 49281: don't follow a 3xx if the response doesn't
// have a Location header.
func TestClientRedirectNoLocation(t *testing.T) {}

func testClientRedirectNoLocation(t *testing.T, mode testMode) {}

// Don't follow a 307/308 if we can't resent the request body.
func TestClientRedirect308NoGetBody(t *testing.T) {}

func testClientRedirect308NoGetBody(t *testing.T, mode testMode) {}

var expectedCookies

var echoCookiesRedirectHandler

func TestClientSendsCookieFromJar(t *testing.T) {}

type TestJar

func (j *TestJar) SetCookies(u *url.URL, cookies []*Cookie) {}

func (j *TestJar) Cookies(u *url.URL) []*Cookie {}

func TestRedirectCookiesJar(t *testing.T) {}

func testRedirectCookiesJar(t *testing.T, mode testMode) {}

func matchReturnedCookies(t *testing.T, expected, given []*Cookie) {}

func TestJarCalls(t *testing.T) {}

func testJarCalls(t *testing.T, mode testMode) {}

type RecordingJar

func (j *RecordingJar) SetCookies(u *url.URL, cookies []*Cookie) {}

func (j *RecordingJar) Cookies(u *url.URL) []*Cookie {}

func (j *RecordingJar) logf(format string, args ...any) {}

func TestStreamingGet(t *testing.T) {}

func testStreamingGet(t *testing.T, mode testMode) {}

type writeCountingConn

func (c *writeCountingConn) Write(p []byte) (int, error) {}

// TestClientWrites verifies that client requests are buffered and we
// don't send a TCP packet per line of the http request + body.
func TestClientWrites(t *testing.T) {}

func testClientWrites(t *testing.T, mode testMode) {}

func TestClientInsecureTransport(t *testing.T) {}

func testClientInsecureTransport(t *testing.T, mode testMode) {}

func TestClientErrorWithRequestURI(t *testing.T) {}

func TestClientWithCorrectTLSServerName(t *testing.T) {}

func testClientWithCorrectTLSServerName(t *testing.T, mode testMode) {}

func TestClientWithIncorrectTLSServerName(t *testing.T) {}

func testClientWithIncorrectTLSServerName(t *testing.T, mode testMode) {}

// Test for golang.org/issue/5829; the Transport should respect TLSClientConfig.ServerName
// when not empty.
//
// tls.Config.ServerName (non-empty, set to "example.com") takes
// precedence over "some-other-host.tld" which previously incorrectly
// took precedence. We don't actually connect to (or even resolve)
// "some-other-host.tld", though, because of the Transport.Dial hook.
//
// The httptest.Server has a cert with "example.com" as its name.
func TestTransportUsesTLSConfigServerName(t *testing.T) {}

func testTransportUsesTLSConfigServerName(t *testing.T, mode testMode) {}

func TestResponseSetsTLSConnectionState(t *testing.T) {}

func testResponseSetsTLSConnectionState(t *testing.T, mode testMode) {}

// Check that an HTTPS client can interpret a particular TLS error
// to determine that the server is speaking HTTP.
// See golang.org/issue/11111.
func TestHTTPSClientDetectsHTTPServer(t *testing.T) {}

func testHTTPSClientDetectsHTTPServer(t *testing.T, mode testMode) {}

// Verify Response.ContentLength is populated. https://golang.org/issue/4126
func TestClientHeadContentLength(t *testing.T) {}

func testClientHeadContentLength(t *testing.T, mode testMode) {}

func TestEmptyPasswordAuth(t *testing.T) {}

func testEmptyPasswordAuth(t *testing.T, mode testMode) {}

func TestBasicAuth(t *testing.T) {}

func TestBasicAuthHeadersPreserved(t *testing.T) {}

func TestStripPasswordFromError(t *testing.T) {}

func TestClientTimeout(t *testing.T) {}

func testClientTimeout(t *testing.T, mode testMode) {}

// Client.Timeout firing before getting to the body
func TestClientTimeout_Headers(t *testing.T) {}

func testClientTimeout_Headers(t *testing.T, mode testMode) {}

// Issue 16094: if Client.Timeout is set but not hit, a Timeout error shouldn't be
// returned.
func TestClientTimeoutCancel(t *testing.T) {}

func testClientTimeoutCancel(t *testing.T, mode testMode) {}

// Issue 49366: if Client.Timeout is set but not hit, no error should be returned.
func TestClientTimeoutDoesNotExpire(t *testing.T) {}

func testClientTimeoutDoesNotExpire(t *testing.T, mode testMode) {}

func TestClientRedirectEatsBody_h1(t *testing.T) {}

func testClientRedirectEatsBody(t *testing.T, mode testMode) {}

type eofReaderFunc

func (f eofReaderFunc) Read(p []byte) (n int, err error) {}

func TestReferer(t *testing.T) {}

type issue15577Tripper

func (issue15577Tripper) RoundTrip(*Request) (*Response, error) {}

// Issue 15577: don't assume the roundtripper's response populates its Request field.
func TestClientRedirectResponseWithoutRequest(t *testing.T) {}

// Issue 4800: copy (some) headers when Client follows a redirect.
// Issue 35104: Since both URLs have the same host (localhost)
// but different ports, sensitive headers like Cookie and Authorization
// are preserved.
func TestClientCopyHeadersOnRedirect(t *testing.T) {}

func testClientCopyHeadersOnRedirect(t *testing.T, mode testMode) {}

// Issue 22233: copy host when Client follows a relative redirect.
func TestClientCopyHostOnRedirect(t *testing.T) {}

func testClientCopyHostOnRedirect(t *testing.T, mode testMode) {}

// Issue 17494: cookies should be altered when Client follows redirects.
func TestClientAltersCookiesOnRedirect(t *testing.T) {}

func testClientAltersCookiesOnRedirect(t *testing.T, mode testMode) {}

// Part of Issue 4800
func TestShouldCopyHeaderOnRedirect(t *testing.T) {}

func TestClientRedirectTypes(t *testing.T) {}

func testClientRedirectTypes(t *testing.T, mode testMode) {}

type issue18239Body

func (b issue18239Body) Read([]byte) (int, error) {}

func (b issue18239Body) Close() error {}

// Issue 18239: make sure the Transport doesn't retry requests with bodies
// if Request.GetBody is not defined.
func TestTransportBodyReadError(t *testing.T) {}

func testTransportBodyReadError(t *testing.T, mode testMode) {}

type roundTripperWithoutCloseIdle

func (roundTripperWithoutCloseIdle) RoundTrip(*Request) (*Response, error) {}

type roundTripperWithCloseIdle

func (roundTripperWithCloseIdle) RoundTrip(*Request) (*Response, error) {}

func (f roundTripperWithCloseIdle) CloseIdleConnections()               {}

func TestClientCloseIdleConnections(t *testing.T) {}

type testRoundTripper

func (t testRoundTripper) RoundTrip(req *Request) (*Response, error) {}

func TestClientPropagatesTimeoutToContext(t *testing.T) {}

// Issue 33545: lock-in the behavior promised by Client.Do's
// docs about request cancellation vs timing out.
func TestClientDoCanceledVsTimeout(t *testing.T) {}

func testClientDoCanceledVsTimeout(t *testing.T, mode testMode) {}

type nilBodyRoundTripper

func (nilBodyRoundTripper) RoundTrip(req *Request) (*Response, error) {}

func TestClientPopulatesNilResponseBody(t *testing.T) {}

// Issue 40382: Client calls Close multiple times on Request.Body.
func TestClientCallsCloseOnlyOnce(t *testing.T) {}

func testClientCallsCloseOnlyOnce(t *testing.T, mode testMode) {}

type issue40382Body

func (b *issue40382Body) Read(p []byte) (int, error) {}

func (b *issue40382Body) Close() error {}

func TestProbeZeroLengthBody(t *testing.T) {}

func testProbeZeroLengthBody(t *testing.T, mode testMode) {}