• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pusher / pusher-http-go / 12285846667

11 Dec 2024 10:17PM UTC coverage: 87.082%. Remained the same
12285846667

Pull #93

github

web-flow
Bump golang.org/x/crypto

Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.0.0-20200709230013-948cd5f35899 to 0.31.0.
- [Commits](https://github.com/golang/crypto/commits/v0.31.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #93: Bump golang.org/x/crypto from 0.0.0-20200709230013-948cd5f35899 to 0.31.0

573 of 658 relevant lines covered (87.08%)

1.99 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.3
/request.go
1
package pusher
2

3
import (
4
        "bytes"
5
        "errors"
6
        "fmt"
7
        "io/ioutil"
8
        "net/http"
9
        "strconv"
10
)
11

12
const (
13
        contentTypeHeaderKey   = "Content-Type"
14
        contentTypeHeaderValue = "application/json"
15
)
16

17
var headers = map[string]string{
18
        "Content-Type":     "application/json",
19
        "X-Pusher-Library": fmt.Sprintf("%s %s", libraryName, libraryVersion),
20
}
21

22
// change timeout to time.Duration
23
func request(client *http.Client, method, url string, body []byte) ([]byte, error) {
2✔
24
        req, err := http.NewRequest(method, url, bytes.NewBuffer(body))
2✔
25

2✔
26
        for key, val := range headers {
4✔
27
                req.Header.Set(http.CanonicalHeaderKey(key), val)
2✔
28
        }
2✔
29

30
        resp, err := client.Do(req)
2✔
31
        if err != nil {
4✔
32
                return nil, err
2✔
33
        }
2✔
34
        defer resp.Body.Close()
2✔
35
        return processResponse(resp)
2✔
36
}
37

38
func processResponse(response *http.Response) ([]byte, error) {
2✔
39
        responseBody, err := ioutil.ReadAll(response.Body)
2✔
40
        if err != nil {
2✔
41
                return nil, err
×
42
        }
×
43
        if response.StatusCode >= 200 && response.StatusCode < 300 {
4✔
44
                return responseBody, nil
2✔
45
        }
2✔
46
        message := fmt.Sprintf("Status Code: %s - %s", strconv.Itoa(response.StatusCode), string(responseBody))
2✔
47
        err = errors.New(message)
2✔
48
        return nil, err
2✔
49
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc