Comments (7)
I did a bit of on-wire sniffing to compare what goupnp does versus what miniupnpc does. This is a working request from miniupunc:
POST /igdupnp/control/WANIPConn1 HTTP/1.1
Host: 192.168.178.1:49000
User-Agent: Darwin/13.0.0, UPnP/1.0, MiniUPnPc/1.9
Content-Length: 271
Content-Type: text/xml
SOAPAction: "urn:schemas-upnp-org:service:WANIPConnection:1#GetStatusInfo"
Connection: Close
Cache-Control: no-cache
Pragma: no-cache
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:GetStatusInfo xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"></u:GetStatusInfo></s:Body></s:Envelope>
This is a failing request from goupnp:
POST /igdupnp/control/WANIPConn1 HTTP/1.1
Host: 192.168.178.1:49000
User-Agent: Go 1.1 package http
Content-Length: 154
CONTENT-TYPE: text/xml; charset="utf-8"
SOAPACTION: urn:schemas-upnp-org:service:WANIPConnection:1#GetStatusInfo
Accept-Encoding: gzip
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body></s:Body></s:Envelope>
This shows several differences:
- miniupunc includes the
<?xml version="1.0" encoding="utf-8"?>
preamble. - miniupunc includes an
<u:GetStatusInfo xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">
element in the SOAP body.
I suspect the latter part is the critical one.
from goupnp.
I did a very quick hack by modifying encodeRequestAction
:
func encodeRequestAction(inAction interface{}) ([]byte, error) {
requestBuf := new(bytes.Buffer)
requestBuf.WriteString(soapPrefix)
requestBuf.WriteString("<u:GetStatusInfo xmlns:u=\"urn:schemas-upnp-org:service:WANIPConnection:1\"></u:GetStatusInfo>")
That indeed fixed the 500 errors.
from goupnp.
You're quite right... I suspect this never worked, and I never tested things that actually required arguments to the action (ugh, lazy me - that's pretty bad). Thanks for reporting this.
I've pushed a fix. It's not pretty... but then, Go's support for controlling namespace prefixes is a pain, and a lot of UPnP servers seem to choke on most of the XML that Go's XML library emits (even though it's valid).
Let me know if that works for you!
from goupnp.
I realised shortly after writing a reply that while this code works for actions with no parameters, I'm not sure that I ever got around to testing actions with parameters. I'll need to do that... Probably setting up some basic unit tests around soap actions.
from goupnp.
I've added a test and confirmed a fix as working with parameters as well now. This should now be in a better state.
from goupnp.
Thanks, this works correctly for me now.
from goupnp.
Excellent, thanks for the confirmation.
from goupnp.
Related Issues (20)
- Unable to find devices most of the time HOT 7
- It's not possible to query ssdp:all HOT 1
- Incorrect err (nil) returned incase of timeout in httpu HOT 6
- Discover UPnP as not active if UPnP not ON in device HOT 4
- Show devices connected to discovered UPnP enabled device. HOT 2
- Why can't i find this upnp device (http://192.168.61.1:5000/rootDesc.xml)? HOT 5
- GetTotalBytesSent() can't parse value, if it's negative HOT 3
- Fail on http post request to router. HOT 12
- httpu multicast fails on multiple interfaces HOT 7
- Please provide example of AV dlna device implementation (audio) HOT 2
- Could you specify some examples? HOT 10
- Making charset dependency optional HOT 6
- SSDPRawSearch: With the same USN, ipv4Response was replaced by ipv6Response, which is not effected for ipv4only client. HOT 1
- Contexts on HTTP calls HOT 6
- httpu: error while parsing response HOT 4
- Any plan to add SSDP Server Support ? HOT 1
- get the IP associated with the interface used to successfully discover the upnp setup ? HOT 26
- feat: context everywhere and non-blocking results HOT 2
- update the guide HOT 1
- Provide an API to use specific ip addresses for discovery HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from goupnp.