Check for http status code.

debian
Martin Dosch 4 years ago
parent 758cb6a3f2
commit c0d7514674

@ -213,10 +213,14 @@ func httpUpload(client *xmpp.Client, jserver string, filePath string) string {
log.Fatal(err)
}
req.Header.Set("Content-Type", mimeType)
_, err = httpClient.Do(req)
resp, err := httpClient.Do(req)
if err != nil {
log.Fatal(err)
}
// Test for http status code "200 OK" or "201 Created"
if resp.StatusCode != 200 && resp.StatusCode != 201 {
log.Fatal("Http upload failed.")
}
// Return http link
return iqHttpUploadSlotXML.Get.URL

Loading…
Cancel
Save