Sfoglia il codice sorgente

integration-cli: fix getTestTokenService not sending header

This utility was setting the content-type header after WriteHeader was
called, and the header was not sent because of that.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 1 anno fa
parent
commit
a9fcb775e5
1 ha cambiato i file con 2 aggiunte e 2 eliminazioni
  1. 2 2
      integration-cli/docker_cli_push_test.go

+ 2 - 2
integration-cli/docker_cli_push_test.go

@@ -235,13 +235,13 @@ func getTestTokenService(status int, body string, retries int) *httptest.Server
 	return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
 	return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
 		mu.Lock()
 		mu.Lock()
 		if retries > 0 {
 		if retries > 0 {
-			w.WriteHeader(http.StatusServiceUnavailable)
 			w.Header().Set("Content-Type", "application/json")
 			w.Header().Set("Content-Type", "application/json")
+			w.WriteHeader(http.StatusServiceUnavailable)
 			w.Write([]byte(`{"errors":[{"code":"UNAVAILABLE","message":"cannot create token at this time"}]}`))
 			w.Write([]byte(`{"errors":[{"code":"UNAVAILABLE","message":"cannot create token at this time"}]}`))
 			retries--
 			retries--
 		} else {
 		} else {
-			w.WriteHeader(status)
 			w.Header().Set("Content-Type", "application/json")
 			w.Header().Set("Content-Type", "application/json")
+			w.WriteHeader(status)
 			w.Write([]byte(body))
 			w.Write([]byte(body))
 		}
 		}
 		mu.Unlock()
 		mu.Unlock()