Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
projectdiscovery
GitHub Repository: projectdiscovery/nuclei
Path: blob/dev/pkg/protocols/utils/utils_test.go
2070 views
1
package utils
2
3
import (
4
"testing"
5
6
"github.com/stretchr/testify/require"
7
)
8
9
func TestCalculateContentLength(t *testing.T) {
10
tests := []struct {
11
name string
12
expected int64
13
contentLengthHeader int64
14
bodyLength int64
15
}{
16
{"content-length-header", 10, 10, 10},
17
{"content-length-header-with-body-length", 10, 10, 1000},
18
{"no-content-length-header-with-body-length", 1000, -1, 1000},
19
{"content-length-header-without-body-length", 10, 10, -1},
20
}
21
for _, test := range tests {
22
t.Run(test.name, func(t *testing.T) {
23
got := CalculateContentLength(test.contentLengthHeader, test.bodyLength)
24
require.Equal(t, test.expected, got)
25
})
26
}
27
}
28
29