-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send propper Onvif headers for event streaming requests.
- Loading branch information
Showing
2 changed files
with
35 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package gonvif | ||
|
||
import ( | ||
"encoding/xml" | ||
|
||
"github.com/eyetowers/gonvif/pkg/generated/onvif/www_w3_org/2005/08/addressing" | ||
"github.com/eyetowers/gonvif/pkg/gonvif/axis" | ||
) | ||
|
||
func ComposeHeaders(ref *addressing.EndpointReferenceType) []any { | ||
// NOTE: Axis returns a SubscriptionId that has to be passed into the PullMessages call as SOAP | ||
// header as-is. We try to mimic this behavior here. | ||
var headers []any | ||
if axisHeader, ok := axis.ToHeader(ref); ok { | ||
headers = append(headers, axisHeader) | ||
} | ||
headers = append(headers, | ||
ReplyToAddressingHeader{Address: "http://www.w3.org/2005/08/addressing/anonymous"}, | ||
ToAddressingHeader{Value: string(*ref.Address)}, | ||
) | ||
return headers | ||
} | ||
|
||
type ToAddressingHeader struct { | ||
XMLName xml.Name `xml:"http://www.w3.org/2005/08/addressing To"` | ||
|
||
Value string `xml:",chardata"` | ||
} | ||
|
||
type ReplyToAddressingHeader struct { | ||
XMLName xml.Name `xml:"http://www.w3.org/2005/08/addressing ReplyTo"` | ||
|
||
Address string `xml:"http://www.w3.org/2005/08/addressing Address"` | ||
} |