summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/nlopes/slack/misc.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2016-11-06 00:07:24 +0100
committerWim <wim@42.be>2016-11-06 00:07:24 +0100
commit37873acfcd328e7c9eaf2e69148de05b8d00a428 (patch)
tree9402715a83f140dda8d102aee6697366546a9382 /vendor/github.com/nlopes/slack/misc.go
parent2dbe0eb55729620ffdfdb7e4f10003564d79c7e1 (diff)
downloadmatterbridge-msglm-37873acfcd328e7c9eaf2e69148de05b8d00a428.tar.gz
matterbridge-msglm-37873acfcd328e7c9eaf2e69148de05b8d00a428.tar.bz2
matterbridge-msglm-37873acfcd328e7c9eaf2e69148de05b8d00a428.zip
Update vendor (slack)
Diffstat (limited to 'vendor/github.com/nlopes/slack/misc.go')
-rw-r--r--vendor/github.com/nlopes/slack/misc.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/vendor/github.com/nlopes/slack/misc.go b/vendor/github.com/nlopes/slack/misc.go
index c0f023cb..57f39104 100644
--- a/vendor/github.com/nlopes/slack/misc.go
+++ b/vendor/github.com/nlopes/slack/misc.go
@@ -9,6 +9,7 @@ import (
"io/ioutil"
"mime/multipart"
"net/http"
+ "net/http/httputil"
"net/url"
"os"
"path/filepath"
@@ -96,6 +97,13 @@ func postWithMultipartResponse(path string, filepath string, values url.Values,
return err
}
defer resp.Body.Close()
+
+ // Slack seems to send an HTML body along with 5xx error codes. Don't parse it.
+ if resp.StatusCode != 200 {
+ logResponse(resp, debug)
+ return fmt.Errorf("Slack server error: %s.", resp.Status)
+ }
+
return parseResponseBody(resp.Body, &intf, debug)
}
@@ -117,3 +125,16 @@ func parseAdminResponse(method string, teamName string, values url.Values, intf
endpoint := fmt.Sprintf(SLACK_WEB_API_FORMAT, teamName, method, time.Now().Unix())
return postForm(endpoint, values, intf, debug)
}
+
+func logResponse(resp *http.Response, debug bool) error {
+ if debug {
+ text, err := httputil.DumpResponse(resp, true)
+ if err != nil {
+ return err
+ }
+
+ logger.Print(text)
+ }
+
+ return nil
+}