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

ghettovoice / gosip / 18541436410

15 Oct 2025 08:14PM UTC coverage: 38.19% (+0.2%) from 37.954%
18541436410

push

github

ghettovoice
Use render options in send request/response methods

8 of 8 new or added lines in 1 file covered. (100.0%)

583 existing lines in 48 files now uncovered.

5347 of 14001 relevant lines covered (38.19%)

5.24 hits per line

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

75.32
/header/content_encoding.go
1
package header
2

3
import (
4
        "fmt"
5
        "io"
6
        "slices"
7
        "strconv"
8

9
        "braces.dev/errtrace"
10
        "github.com/ghettovoice/abnf"
11

12
        "github.com/ghettovoice/gosip/internal/grammar"
13
        "github.com/ghettovoice/gosip/internal/stringutil"
14
)
15

16
type ContentEncoding []string
17

18
func (ContentEncoding) CanonicName() Name { return "Content-Encoding" }
5✔
19

20
func (ContentEncoding) CompactName() Name { return "e" }
1✔
21

22
func (hdr ContentEncoding) RenderTo(w io.Writer, opts ...any) error {
7✔
23
        if hdr == nil {
8✔
24
                return nil
1✔
25
        }
1✔
26
        if _, err := fmt.Fprint(w, hdr.name(opts...), ": "); err != nil {
6✔
UNCOV
27
                return errtrace.Wrap(err)
×
UNCOV
28
        }
×
29
        return errtrace.Wrap(hdr.renderValue(w))
6✔
30
}
31

32
func (hdr ContentEncoding) name(opts ...any) Name {
6✔
33
        var compact RenderCompact
6✔
34
        for _, o := range opts {
10✔
35
                if v, ok := o.(RenderCompact); ok {
8✔
36
                        compact = v
4✔
37
                }
4✔
38
        }
39
        if compact {
7✔
40
                return hdr.CompactName()
1✔
41
        }
1✔
42
        return hdr.CanonicName()
5✔
43
}
44

45
func (hdr ContentEncoding) renderValue(w io.Writer) error {
9✔
46
        return errtrace.Wrap(renderHdrEntries(w, hdr))
9✔
47
}
9✔
48

49
func (hdr ContentEncoding) Render(opts ...any) string {
5✔
50
        if hdr == nil {
6✔
51
                return ""
1✔
52
        }
1✔
53
        sb := stringutil.GetStringBuilder()
4✔
54
        defer stringutil.FreeStringBuilder(sb)
4✔
55
        _ = hdr.RenderTo(sb, opts...)
4✔
56
        return sb.String()
4✔
57
}
58

59
func (hdr ContentEncoding) String() string {
3✔
60
        sb := stringutil.GetStringBuilder()
3✔
61
        defer stringutil.FreeStringBuilder(sb)
3✔
62
        _ = hdr.renderValue(sb)
3✔
63
        return sb.String()
3✔
64
}
3✔
65

66
func (hdr ContentEncoding) Format(f fmt.State, verb rune) {
×
67
        switch verb {
×
UNCOV
68
        case 's':
×
UNCOV
69
                if f.Flag('+') {
×
UNCOV
70
                        _ = hdr.RenderTo(f)
×
UNCOV
71
                        return
×
UNCOV
72
                }
×
UNCOV
73
                fmt.Fprint(f, hdr.String())
×
UNCOV
74
                return
×
UNCOV
75
        case 'q':
×
UNCOV
76
                fmt.Fprint(f, strconv.Quote(hdr.String()))
×
UNCOV
77
                return
×
UNCOV
78
        default:
×
UNCOV
79
                type hideMethods ContentEncoding
×
UNCOV
80
                type ContentEncoding hideMethods
×
UNCOV
81
                fmt.Fprintf(f, fmt.FormatString(f, verb), ContentEncoding(hdr))
×
UNCOV
82
                return
×
83
        }
84
}
85

86
func (hdr ContentEncoding) Clone() Header { return slices.Clone(hdr) }
3✔
87

88
func (hdr ContentEncoding) Equal(val any) bool {
19✔
89
        var other ContentEncoding
19✔
90
        switch v := val.(type) {
19✔
91
        case ContentEncoding:
16✔
92
                other = v
16✔
93
        case *ContentEncoding:
2✔
94
                if v == nil {
3✔
95
                        return false
1✔
96
                }
1✔
97
                other = *v
1✔
98
        default:
1✔
99
                return false
1✔
100
        }
101
        return slices.EqualFunc(hdr, other, func(enc1, enc2 string) bool { return stringutil.LCase(enc1) == stringutil.LCase(enc2) })
32✔
102
}
103

104
func (hdr ContentEncoding) IsValid() bool {
4✔
105
        return len(hdr) > 0 && !slices.ContainsFunc(hdr, func(enc string) bool { return !grammar.IsToken(enc) })
7✔
106
}
107

108
func buildFromContentEncodingNode(node *abnf.Node) ContentEncoding {
2✔
109
        encNodes := node.GetNodes("token")
2✔
110
        h := make(ContentEncoding, len(encNodes))
2✔
111
        for i, encNode := range encNodes {
6✔
112
                h[i] = encNode.String()
4✔
113
        }
4✔
114
        return h
2✔
115
}
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

© 2026 Coveralls, Inc