mirror of
https://github.com/kerberos-io/onvif.git
synced 2026-08-23 15:08:33 +00:00
- Added EndpointRefAddress to DeviceParams for better endpoint management. - Updated FilterType to use pointers for TopicExpression and MessageContent. - Refactored SendSoapWithDigest to strip WS-Security headers to avoid credential duplication. - Updated package imports to reflect new repository structure. - Introduced ReadAndParse function for improved HTTP response handling in SDK.
26 lines
637 B
Go
26 lines
637 B
Go
package sdk
|
|
|
|
import (
|
|
"context"
|
|
"encoding/xml"
|
|
"io"
|
|
"net/http"
|
|
|
|
"github.com/juju/errors"
|
|
)
|
|
|
|
// ReadAndParse reads the body of the given HTTP reply and unmarshals it into
|
|
// reply. The tag identifies the ONVIF action for diagnostic purposes.
|
|
func ReadAndParse(ctx context.Context, httpReply *http.Response, reply interface{}, tag string) error {
|
|
// TODO(jfsmig): extract the deadline from ctx.Deadline() and apply it on the reply reading
|
|
b, err := io.ReadAll(httpReply.Body)
|
|
if err != nil {
|
|
return errors.Annotate(err, "read")
|
|
}
|
|
|
|
httpReply.Body.Close()
|
|
|
|
err = xml.Unmarshal(b, reply)
|
|
return errors.Annotate(err, "decode")
|
|
}
|