Add digest to request
This commit is contained in:
parent
4b143a6650
commit
b223a25055
3 changed files with 16 additions and 4 deletions
17
main.go
17
main.go
|
@ -9,6 +9,7 @@ import (
|
|||
"os"
|
||||
|
||||
"crispbyte.dev/sig-auth/client"
|
||||
"github.com/opencontainers/go-digest"
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
|
@ -30,10 +31,18 @@ func main() {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := client.Post(
|
||||
"http://localhost:8080/post",
|
||||
"application/json",
|
||||
bytes.NewBuffer(json_data))
|
||||
id := digest.FromBytes(json_data)
|
||||
|
||||
req, err := http.NewRequest("POST", "http://localhost:8080/post", bytes.NewBuffer(json_data))
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
req.Header.Add("Content-Digest", string(id.Algorithm())+"="+id.Encoded())
|
||||
req.Header.Add("Content-Type", "application/json")
|
||||
|
||||
resp, err := client.Do(req)
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue