Skip to content

Commit b641ffe

Browse files
committed
add Content-Digest header to init script response
1 parent aa63880 commit b641ffe

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

coderd/initscript.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package coderd
22

33
import (
4+
"crypto/sha256"
5+
"encoding/base64"
46
"fmt"
57
"net/http"
68
"strings"
@@ -34,7 +36,10 @@ func (api *API) initScript(rw http.ResponseWriter, r *http.Request) {
3436
script = strings.ReplaceAll(script, "${ACCESS_URL}", api.AccessURL.String()+"/")
3537
script = strings.ReplaceAll(script, "${AUTH_TYPE}", "token")
3638

39+
scriptBytes := []byte(script)
40+
hash := sha256.Sum256(scriptBytes)
41+
rw.Header().Set("Content-Digest", fmt.Sprintf("sha256:%x", base64.StdEncoding.EncodeToString(hash[:])))
3742
rw.Header().Set("Content-Type", "text/plain; charset=utf-8")
3843
rw.WriteHeader(http.StatusOK)
39-
_, _ = rw.Write([]byte(script))
44+
_, _ = rw.Write(scriptBytes)
4045
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy