mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +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 (
|
||||
"bytes"
|
||||
"encoding/xml"
|
||||
"github.com/pkg/errors"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// 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 {
|
||||
// log.Stderr(function, r.StatusCode)
|
||||
err = errors.New("Error " + strconv.Itoa(r.StatusCode) + " for " + function)
|
||||
data, readErr := ioutil.ReadAll(r.Body)
|
||||
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
|
||||
return
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user