From 21024fcd5652b8f78c8041d59a8ec7c7732e2479 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Wed, 10 Apr 2019 19:54:46 -0400 Subject: [PATCH] sign the content-type instead of content-length --- activity.go | 2 +- zig.go | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/activity.go b/activity.go index 5118144..4e5cb93 100644 --- a/activity.go +++ b/activity.go @@ -82,8 +82,8 @@ func PostJunk(keyname string, key *rsa.PrivateKey, url string, j map[string]inte if err != nil { return err } - zig(keyname, key, req, buf.Bytes()) req.Header.Set("Content-Type", theonetruename) + zig(keyname, key, req, buf.Bytes()) resp, err := client.Do(req) if err != nil { return err diff --git a/zig.go b/zig.go index 393e868..dddae5d 100644 --- a/zig.go +++ b/zig.go @@ -28,7 +28,6 @@ import ( "io" "net/http" "regexp" - "strconv" "strings" "time" ) @@ -54,7 +53,7 @@ func sb64sha256(content []byte) string { } 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 for _, h := range headers { var s string @@ -73,13 +72,8 @@ func zig(keyname string, key *rsa.PrivateKey, req *http.Request, content []byte) s = req.URL.Hostname() req.Header.Set(h, s) } - case "content-length": + case "content-type": s = req.Header.Get(h) - if s == "" { - s = strconv.Itoa(len(content)) - req.Header.Set(h, s) - req.ContentLength = int64(len(content)) - } case "digest": s = req.Header.Get(h) if s == "" {