From ad53c5d8594dd4f6dad7c56824910b6dda1f47af Mon Sep 17 00:00:00 2001 From: Nitish Tiwari Date: Fri, 13 Oct 2017 13:29:01 +0530 Subject: [PATCH] Remove body from POST request in webhook (#5067) When webhook notification is configured, Minio server tries to lookup the webhook endpoint by making a POST request with body set as releasetag. We can remove the body from the POST request as the POST body does not add any specific value. This discussion on IETF group says empty POSTs are okay http://lists.w3.org/Archives/Public/ietf-http-wg/2010JulSep/0272.html Fixes: https://github.com/minio/minio/issues/5066 --- cmd/notify-webhook.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cmd/notify-webhook.go b/cmd/notify-webhook.go index 8a0556847..00b79de45 100644 --- a/cmd/notify-webhook.go +++ b/cmd/notify-webhook.go @@ -91,10 +91,9 @@ func isNetErrorIgnored(err error) bool { } // Lookup endpoint address by successfully POSTting -// a JSON which would send out minio release. +// empty body. func lookupEndpoint(urlStr string) error { - minioRelease := bytes.NewReader([]byte(ReleaseTag)) - req, err := http.NewRequest("POST", urlStr, minioRelease) + req, err := http.NewRequest("POST", urlStr, bytes.NewReader([]byte(""))) if err != nil { return err } @@ -107,8 +106,8 @@ func lookupEndpoint(urlStr string) error { }, } - // Set content-type. - req.Header.Set("Content-Type", "application/json") + // Set content-length to zero as there is no payload. + req.ContentLength = 0 // Set proper server user-agent. req.Header.Set("User-Agent", globalServerUserAgent)