Signature-V4: Dump the request with error message on signature mismatch. (#2734)

fixes #2691
This commit is contained in:
Krishna Srinivas
2016-09-19 22:47:46 +05:30
committed by Harshavardhana
parent 725df557b5
commit a955676986
5 changed files with 40 additions and 1 deletions

View File

@@ -32,6 +32,8 @@ import (
"sync"
"syscall"
"encoding/json"
"github.com/pkg/profile"
)
@@ -327,3 +329,20 @@ func startMonitorShutdownSignal(onExitFn onExitFunc) error {
// Successfully started routine.
return nil
}
// dump the request into a string in JSON format.
func dumpRequest(r *http.Request) string {
header := cloneHeader(r.Header)
header.Set("Host", r.Host)
req := struct {
Method string `json:"method"`
Path string `json:"path"`
Query string `json:"query"`
Header http.Header `json:"header"`
}{r.Method, r.URL.Path, r.URL.RawQuery, header}
jsonBytes, err := json.Marshal(req)
if err != nil {
return "<error dumping request>"
}
return string(jsonBytes)
}