diff --git a/github/repos.go b/github/repos.go index a57b260e95a..6631c6745d0 100644 --- a/github/repos.go +++ b/github/repos.go @@ -249,7 +249,7 @@ func (s *RepositoriesService) ListByOrg(ctx context.Context, org string, opts *R // TODO: remove custom Accept headers when APIs fully launch. acceptHeaders := []string{mediaTypeTopicsPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept:", strings.Join(acceptHeaders, ", ")) var repos []*Repository resp, err := s.client.Do(ctx, req, &repos) @@ -368,7 +368,7 @@ func (s *RepositoriesService) Create(ctx context.Context, org string, repo *Repo } acceptHeaders := []string{mediaTypeRepositoryTemplatePreview, mediaTypeRepositoryVisibilityPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept:", strings.Join(acceptHeaders, ", ")) r := new(Repository) resp, err := s.client.Do(ctx, req, r) if err != nil { @@ -427,7 +427,7 @@ func (s *RepositoriesService) Get(ctx context.Context, owner, repo string) (*Rep mediaTypeRepositoryTemplatePreview, mediaTypeRepositoryVisibilityPreview, } - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept:", strings.Join(acceptHeaders, ", ")) repository := new(Repository) resp, err := s.client.Do(ctx, req, repository) @@ -490,7 +490,7 @@ func (s *RepositoriesService) Edit(ctx context.Context, owner, repo string, repo } acceptHeaders := []string{mediaTypeRepositoryTemplatePreview, mediaTypeRepositoryVisibilityPreview} - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + req.Header.Set("Accept:", strings.Join(acceptHeaders, ", ")) r := new(Repository) resp, err := s.client.Do(ctx, req, r) if err != nil { @@ -1308,7 +1308,7 @@ func (s *RepositoriesService) ListAllTopics(ctx context.Context, owner, repo str } // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeTopicsPreview) + req.Header.Set("Accept:", mediaTypeTopicsPreview) topics := new(repositoryTopics) resp, err := s.client.Do(ctx, req, topics) @@ -1336,7 +1336,7 @@ func (s *RepositoriesService) ReplaceAllTopics(ctx context.Context, owner, repo } // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeTopicsPreview) + req.Header.Set("Accept:", mediaTypeTopicsPreview) t = new(repositoryTopics) resp, err := s.client.Do(ctx, req, t) diff --git a/github/repos_test.go b/github/repos_test.go index bbe82ea6a75..0acbce00aae 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -22,7 +22,7 @@ func TestRepositoriesService_List_authenticatedUser(t *testing.T) { wantAcceptHeaders := []string{mediaTypeTopicsPreview, mediaTypeRepositoryVisibilityPreview} mux.HandleFunc("/user/repos", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", ")) + testHeader(t, r, "Accept:", strings.Join(wantAcceptHeaders, ", ")) fmt.Fprint(w, `[{"id":1},{"id":2}]`) }) @@ -59,7 +59,7 @@ func TestRepositoriesService_List_specifiedUser(t *testing.T) { wantAcceptHeaders := []string{mediaTypeTopicsPreview, mediaTypeRepositoryVisibilityPreview} mux.HandleFunc("/users/u/repos", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", ")) + testHeader(t, r, "Accept:", strings.Join(wantAcceptHeaders, ", ")) testFormValues(t, r, values{ "visibility": "public", "affiliation": "owner,collaborator", @@ -96,7 +96,7 @@ func TestRepositoriesService_List_specifiedUser_type(t *testing.T) { wantAcceptHeaders := []string{mediaTypeTopicsPreview, mediaTypeRepositoryVisibilityPreview} mux.HandleFunc("/users/u/repos", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", ")) + testHeader(t, r, "Accept:", strings.Join(wantAcceptHeaders, ", ")) testFormValues(t, r, values{ "type": "owner", }) @@ -230,7 +230,7 @@ func TestRepositoriesService_Create_user(t *testing.T) { json.NewDecoder(r.Body).Decode(v) testMethod(t, r, "POST") - testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", ")) + testHeader(t, r, "Accept:", strings.Join(wantAcceptHeaders, ", ")) want := &createRepoRequest{Name: String("n")} if !reflect.DeepEqual(v, want) { t.Errorf("Request body = %+v, want %+v", v, want) @@ -280,7 +280,7 @@ func TestRepositoriesService_Create_org(t *testing.T) { json.NewDecoder(r.Body).Decode(v) testMethod(t, r, "POST") - testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", ")) + testHeader(t, r, "Accept:", strings.Join(wantAcceptHeaders, ", ")) want := &createRepoRequest{Name: String("n")} if !reflect.DeepEqual(v, want) { t.Errorf("Request body = %+v, want %+v", v, want) @@ -356,7 +356,7 @@ func TestRepositoriesService_Get(t *testing.T) { wantAcceptHeaders := []string{mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview, mediaTypeRepositoryTemplatePreview, mediaTypeRepositoryVisibilityPreview} mux.HandleFunc("/repos/o/r", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", ")) + testHeader(t, r, "Accept:", strings.Join(wantAcceptHeaders, ", ")) fmt.Fprint(w, `{"id":1,"name":"n","description":"d","owner":{"login":"l"},"license":{"key":"mit"}}`) }) @@ -476,7 +476,7 @@ func TestRepositoriesService_Edit(t *testing.T) { json.NewDecoder(r.Body).Decode(v) testMethod(t, r, "PATCH") - testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", ")) + testHeader(t, r, "Accept:", strings.Join(wantAcceptHeaders, ", ")) if !reflect.DeepEqual(v, input) { t.Errorf("Request body = %+v, want %+v", v, input) } @@ -1893,7 +1893,7 @@ func TestRepositoriesService_ListAllTopics(t *testing.T) { mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeTopicsPreview) + testHeader(t, r, "Accept:", mediaTypeTopicsPreview) fmt.Fprint(w, `{"names":["go", "go-github", "github"]}`) }) @@ -1929,7 +1929,7 @@ func TestRepositoriesService_ListAllTopics_emptyTopics(t *testing.T) { mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeTopicsPreview) + testHeader(t, r, "Accept:", mediaTypeTopicsPreview) fmt.Fprint(w, `{"names":[]}`) }) @@ -1951,7 +1951,7 @@ func TestRepositoriesService_ReplaceAllTopics(t *testing.T) { mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") - testHeader(t, r, "Accept", mediaTypeTopicsPreview) + testHeader(t, r, "Accept:", mediaTypeTopicsPreview) fmt.Fprint(w, `{"names":["go", "go-github", "github"]}`) }) @@ -1987,7 +1987,7 @@ func TestRepositoriesService_ReplaceAllTopics_nilSlice(t *testing.T) { mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") - testHeader(t, r, "Accept", mediaTypeTopicsPreview) + testHeader(t, r, "Accept:", mediaTypeTopicsPreview) testBody(t, r, `{"names":[]}`+"\n") fmt.Fprint(w, `{"names":[]}`) }) @@ -2010,7 +2010,7 @@ func TestRepositoriesService_ReplaceAllTopics_emptySlice(t *testing.T) { mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") - testHeader(t, r, "Accept", mediaTypeTopicsPreview) + testHeader(t, r, "Accept:", mediaTypeTopicsPreview) testBody(t, r, `{"names":[]}`+"\n") fmt.Fprint(w, `{"names":[]}`) })