diff pkg/soap/soap.go @ 1810:7ee9bdaac336

Waterway gauge import: Added support for username/password.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 15 Jan 2019 18:09:10 +0100
parents a244b18cb916
children 6a44a89ffb51
line wrap: on
line diff
--- a/pkg/soap/soap.go	Tue Jan 15 17:02:51 2019 +0100
+++ b/pkg/soap/soap.go	Tue Jan 15 18:09:10 2019 +0100
@@ -17,6 +17,7 @@
 	"bytes"
 	"crypto/tls"
 	"encoding/xml"
+	"fmt"
 	"io/ioutil"
 	"log"
 	"math/rand"
@@ -270,10 +271,15 @@
 	}
 
 	client := &http.Client{Transport: tr}
+
 	res, err := client.Do(req)
 	if err != nil {
 		return err
 	}
+	if res.StatusCode < http.StatusOK || res.StatusCode > 299 {
+		return fmt.Errorf(
+			"HTTP error: %d (%s)", res.StatusCode, http.StatusText(res.StatusCode))
+	}
 	defer res.Body.Close()
 
 	rawbody, err := ioutil.ReadAll(res.Body)