@@ -2529,35 +2529,6 @@ func TestRegistryAsCacheMutationAPIs(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
// TestCheckContextNotifier makes sure the API endpoints get a ResponseWriter
|
||||
// that implements http.ContextNotifier.
|
||||
func TestCheckContextNotifier(t *testing.T) {
|
||||
env := newTestEnv(t, false)
|
||||
defer env.Shutdown()
|
||||
|
||||
// Register a new endpoint for testing
|
||||
env.app.router.Handle("/unittest/{name}/", env.app.dispatcher(func(ctx *Context, r *http.Request) http.Handler {
|
||||
return handlers.MethodHandler{
|
||||
"GET": http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if _, ok := w.(http.CloseNotifier); !ok {
|
||||
t.Fatal("could not cast ResponseWriter to CloseNotifier")
|
||||
}
|
||||
w.WriteHeader(200)
|
||||
}),
|
||||
}
|
||||
}))
|
||||
|
||||
resp, err := http.Get(env.server.URL + "/unittest/reponame/")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error issuing request: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
t.Fatalf("wrong status code - expected 200, got %d", resp.StatusCode)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProxyManifestGetByTag(t *testing.T) {
|
||||
truthConfig := configuration.Configuration{
|
||||
Storage: configuration.Storage{
|
||||
|
@@ -27,13 +27,7 @@ func closeResources(handler http.Handler, closers ...io.Closer) http.Handler {
|
||||
// The copy will be limited to `limit` bytes, if limit is greater than zero.
|
||||
func copyFullPayload(ctx context.Context, responseWriter http.ResponseWriter, r *http.Request, destWriter io.Writer, limit int64, action string) error {
|
||||
// Get a channel that tells us if the client disconnects
|
||||
var clientClosed <-chan bool
|
||||
if notifier, ok := responseWriter.(http.CloseNotifier); ok {
|
||||
clientClosed = notifier.CloseNotify()
|
||||
} else {
|
||||
dcontext.GetLogger(ctx).Warnf("the ResponseWriter does not implement CloseNotifier (type: %T)", responseWriter)
|
||||
}
|
||||
|
||||
clientClosed := r.Context().Done()
|
||||
var body = r.Body
|
||||
if limit > 0 {
|
||||
body = http.MaxBytesReader(responseWriter, body, limit)
|
||||
|
Reference in New Issue
Block a user