sign the content-type instead of content-length
This commit is contained in:
parent
d3b4e07565
commit
21024fcd56
|
@ -82,8 +82,8 @@ func PostJunk(keyname string, key *rsa.PrivateKey, url string, j map[string]inte
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
zig(keyname, key, req, buf.Bytes())
|
|
||||||
req.Header.Set("Content-Type", theonetruename)
|
req.Header.Set("Content-Type", theonetruename)
|
||||||
|
zig(keyname, key, req, buf.Bytes())
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
10
zig.go
10
zig.go
|
@ -28,7 +28,6 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -54,7 +53,7 @@ func sb64sha256(content []byte) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func zig(keyname string, key *rsa.PrivateKey, req *http.Request, content []byte) {
|
func zig(keyname string, key *rsa.PrivateKey, req *http.Request, content []byte) {
|
||||||
headers := []string{"(request-target)", "date", "host", "content-length", "digest"}
|
headers := []string{"(request-target)", "date", "host", "content-type", "digest"}
|
||||||
var stuff []string
|
var stuff []string
|
||||||
for _, h := range headers {
|
for _, h := range headers {
|
||||||
var s string
|
var s string
|
||||||
|
@ -73,13 +72,8 @@ func zig(keyname string, key *rsa.PrivateKey, req *http.Request, content []byte)
|
||||||
s = req.URL.Hostname()
|
s = req.URL.Hostname()
|
||||||
req.Header.Set(h, s)
|
req.Header.Set(h, s)
|
||||||
}
|
}
|
||||||
case "content-length":
|
case "content-type":
|
||||||
s = req.Header.Get(h)
|
s = req.Header.Get(h)
|
||||||
if s == "" {
|
|
||||||
s = strconv.Itoa(len(content))
|
|
||||||
req.Header.Set(h, s)
|
|
||||||
req.ContentLength = int64(len(content))
|
|
||||||
}
|
|
||||||
case "digest":
|
case "digest":
|
||||||
s = req.Header.Get(h)
|
s = req.Header.Get(h)
|
||||||
if s == "" {
|
if s == "" {
|
||||||
|
|
Loading…
Reference in New Issue