Skip to content

Preserve an explicit Content-Type returned through github.Response #11

Description

@tylergannon

Problem

In v0.2.0, writeResults copies headers from the service's *github.Response, then unconditionally replaces Content-Type with application/json for JSON bodies.

That contradicts the documented behavior that a returned response can set explicit headers and prevents a GitHub-compatible implementation from returning application/json; charset=utf-8.

Reproduction

Return a value plus:

&github.Response{Response: &http.Response{
    StatusCode: http.StatusCreated,
    Header: http.Header{
        "Content-Type": {"application/json; charset=utf-8"},
    },
}}

A real go-github client observes Content-Type: application/json.

Requested behavior

Set application/json only when no Content-Type has already been supplied. Add a real go-github round-trip test proving an explicit Content-Type survives.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions