mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-24 23:12:31 +00:00
[NOD-505] Try reading the response in case of upnp error (#576)
This commit is contained in:
parent
2174a0a7f2
commit
20819ca4cd
@ -35,13 +35,15 @@ package serverutils
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"github.com/pkg/errors"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NAT is an interface representing a NAT traversal options for example UPNP or
|
// NAT is an interface representing a NAT traversal options for example UPNP or
|
||||||
@ -313,8 +315,13 @@ func soapRequest(url, function, message string) (replyXML []byte, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if r.StatusCode >= 400 {
|
if r.StatusCode >= 400 {
|
||||||
// log.Stderr(function, r.StatusCode)
|
data, readErr := ioutil.ReadAll(r.Body)
|
||||||
err = errors.New("Error " + strconv.Itoa(r.StatusCode) + " for " + function)
|
if readErr != nil {
|
||||||
|
err = errors.Wrapf(readErr, "Error %d for %s", r.StatusCode, function)
|
||||||
|
} else {
|
||||||
|
err = errors.Errorf("Error %d for %s. Response: %s", r.StatusCode, function, data)
|
||||||
|
}
|
||||||
|
|
||||||
r = nil
|
r = nil
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user