Skip to content
quarry Artifact [dd8280fa86]
Login

Artifact [dd8280fa86]

Artifact dd8280fa86ea40e7f7566cba8cda25153645f37cd29a981e8ff9530648a6f7bd:


package main

import (
	"net/http"
	"testing"
)

// The server bounds how long a client may take to send its headers and
// how long an idle connection may sit, and sets no whole-response write
// or read timeout, because either would cut off healthy live streams
// and long uploads; streams carry their own per-frame deadline instead.
func TestTheServerCarriesHeaderAndIdleTimeoutsButNoStreamKiller(t *testing.T) {
	h := http.NotFoundHandler()
	srv := newServer(h)
	if srv.ReadHeaderTimeout <= 0 {
		t.Fatal("FAIL: no header read timeout")
	}
	t.Log("ok: header reads carry a deadline")
	if srv.IdleTimeout <= 0 {
		t.Fatal("FAIL: no idle timeout")
	}
	t.Log("ok: idle connections carry a deadline")
	if srv.WriteTimeout != 0 || srv.ReadTimeout != 0 {
		t.Fatalf("FAIL: a whole-response timeout would end live streams (write %v, read %v)",
			srv.WriteTimeout, srv.ReadTimeout)
	}
	t.Log("ok: no whole-response timeout")
	if srv.Handler == nil {
		t.Fatal("FAIL: the server serves no handler")
	}
	t.Log("ok: the handler is served as given")
}