Skip to content

Commit

Permalink
ci: enable golanglint "canonicalheader" linter (#2876)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgrinds committed May 6, 2024
1 parent 138a20a commit 38209ef
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ linters:
- asasalint
- bidichk
- bodyclose
- canonicalheader
- contextcheck
- copyloopvar
- dogsled
Expand Down
4 changes: 2 additions & 2 deletions cmd/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ func (a *Admin) startServer() {
}

func (a *Admin) APISD(w http.ResponseWriter, r *http.Request) {
w.Header().Set("content-type", "application/json")
w.Header().Set("Content-Type", "application/json")
if a.httpSD.AuthBasic.Username != "" {
user, pass, ok := r.BasicAuth()
if !ok || !a.verifyAuth(user, pass) {
w.Header().Set("WWW-Authenticate", `Basic realm="api"`)
w.Header().Set("Www-Authenticate", `Basic realm="api"`)
http.Error(w, "Unauthorized", http.StatusUnauthorized)
return
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/collectors/storagegrid/rest/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (c *Client) getRest(request string) ([]byte, error) {
if err != nil {
return nil, err
}
c.request.Header.Set("accept", "application/json")
c.request.Header.Set("Accept", "application/json")
c.request.Header.Set("Authorization", "Bearer "+c.token)
return c.invoke()
}
Expand Down Expand Up @@ -373,7 +373,7 @@ func (c *Client) fetchTokenWithAuthRetry() error {
if err != nil {
return err
}
req.Header.Set("accept", "application/json")
req.Header.Set("Accept", "application/json")
req.Header.Set("Content-Type", "application/json")

// send request to server
Expand Down
6 changes: 3 additions & 3 deletions cmd/exporters/prometheus/httpd.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (p *Prometheus) denyAccess(w http.ResponseWriter, r *http.Request) {

p.Logger.Debug().Msgf("(httpd) denied request [%s] (%s)", r.RequestURI, r.RemoteAddr)
w.WriteHeader(http.StatusForbidden)
w.Header().Set("content-type", "text/plain")
w.Header().Set("Content-Type", "text/plain")
_, err := w.Write([]byte("403 Forbidden"))
if err != nil {
p.Logger.Error().Stack().Err(err).Msg("error")
Expand Down Expand Up @@ -136,7 +136,7 @@ func (p *Prometheus) ServeMetrics(w http.ResponseWriter, r *http.Request) {
}

w.WriteHeader(http.StatusOK)
w.Header().Set("content-type", "text/plain")
w.Header().Set("Content-Type", "text/plain")
_, err := w.Write(bytes.Join(data, []byte("\n")))
if err != nil {
p.Logger.Error().Err(err).Msg("write metrics")
Expand Down Expand Up @@ -273,7 +273,7 @@ func (p *Prometheus) ServeInfo(w http.ResponseWriter, r *http.Request) {
bodyFlat := fmt.Sprintf(htmlTemplate, poller, poller, poller, numCollectors, numObjects, numMetrics, strings.Join(body, "\n\n"))

w.WriteHeader(http.StatusOK)
w.Header().Set("content-type", "text/html")
w.Header().Set("Content-Type", "text/html")
_, err := w.Write([]byte(bodyFlat))
if err != nil {
p.Logger.Error().Stack().Err(err).Msg("error")
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/rest/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (c *Client) GetRest(request string) ([]byte, error) {
if err != nil {
return nil, err
}
c.request.Header.Set("accept", "application/json")
c.request.Header.Set("Accept", "application/json")
pollerAuth, err := c.auth.GetPollerAuth()
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/ontapi/zapi/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func New(poller *conf.Poller, c *auth.Credentials) (*Client, error) {
return nil, err
}

request.Header.Set("Content-type", "text/xml")
request.Header.Set("Content-Type", "text/xml")
request.Header.Set("Charset", "utf-8")

transport, err = c.Transport(request)
Expand Down

0 comments on commit 38209ef

Please sign in to comment.