-
Notifications
You must be signed in to change notification settings - Fork 73
/
padding.go
51 lines (41 loc) · 903 Bytes
/
padding.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"fmt"
)
type PaddingMethod int
const (
PaddingHeadersNone PaddingMethod = iota
PaddingHeadersASCIISame
)
var (
PaddingMethods = []PaddingMethod{
PaddingHeadersNone,
// The other ones were working only in cloudflare bug
// PaddingHeadersUnicodeSame,
// PaddingHeadersASCIISame,
}
PaddingHeaderCount = 100
)
func (p PaddingMethod) Headers() (headers Headers) {
switch p {
case PaddingHeadersNone:
// No headers
case PaddingHeadersASCIISame:
for i := 0; i < PaddingHeaderCount; i++ {
headers = append(headers, Header{"header", "val"})
}
default:
panic(fmt.Errorf("invalid padding header header: %#v", p))
}
return
}
func (p PaddingMethod) String() string {
switch p {
case PaddingHeadersNone:
return "no padding headers"
case PaddingHeadersASCIISame:
return "pad with same ASCII header"
default:
return "unknown padding method"
}
}