From 73c6c11985e9d02f05f90e4d9f2881b5890bcb27 Mon Sep 17 00:00:00 2001 From: Denys Smirnov Date: Sat, 22 May 2021 22:27:41 +0300 Subject: [PATCH] Parse error message for non-OK status codes. --- soap/soap.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/soap/soap.go b/soap/soap.go index 29e89f2..c720bec 100644 --- a/soap/soap.go +++ b/soap/soap.go @@ -54,7 +54,7 @@ func (client *SOAPClient) PerformAction(actionNamespace, actionName string, inAc return fmt.Errorf("goupnp: error performing SOAP HTTP request: %v", err) } defer response.Body.Close() - if response.StatusCode != 200 { + if response.StatusCode != 200 && response.ContentLength == 0 { return fmt.Errorf("goupnp: SOAP request got HTTP %s", response.Status) } @@ -66,6 +66,8 @@ func (client *SOAPClient) PerformAction(actionNamespace, actionName string, inAc if responseEnv.Body.Fault != nil { return responseEnv.Body.Fault + } else if response.StatusCode != 200 { + return fmt.Errorf("goupnp: SOAP request got HTTP %s", response.Status) } if outAction != nil {