Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/api/http_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ func NewHTTPClient(opts ClientOptions) (*http.Client, error) {
func inspectableMIMEType(t string) bool {
return strings.HasPrefix(t, "text/") ||
strings.HasPrefix(t, "application/x-www-form-urlencoded") ||
// /octocat returns ASCII art tagged as application/octocat-stream.
// Treat it as inspectable so --verbose actually shows the response.
strings.HasPrefix(t, "application/octocat-stream") ||
jsonTypeRE.MatchString(t)
}

Expand Down
21 changes: 21 additions & 0 deletions pkg/api/http_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,24 @@ func printPendingMocks(mocks []gock.Mock) string {
}
return fmt.Sprintf("%d unmatched mocks: %s", len(paths), strings.Join(paths, ", "))
}

func TestInspectableMIMEType(t *testing.T) {
for _, tt := range []struct {
mime string
want bool
}{
{"text/plain", true},
{"text/html; charset=utf-8", true},
{"application/json", true},
{"application/vnd.github+json", true},
{"application/x-www-form-urlencoded", true},
// /octocat. See #210.
{"application/octocat-stream", true},
{"image/png", false},
{"application/octet-stream", false},
} {
if got := inspectableMIMEType(tt.mime); got != tt.want {
t.Errorf("inspectableMIMEType(%q) = %v, want %v", tt.mime, got, tt.want)
}
}
}