Code Monkey home page Code Monkey logo

Comments (7)

wichert avatar wichert commented on June 1, 2024

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:

  1. miniupunc includes the <?xml version="1.0" encoding="utf-8"?> preamble.
  2. 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.

wichert avatar wichert commented on June 1, 2024

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.

huin avatar huin commented on June 1, 2024

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.

huin avatar huin commented on June 1, 2024

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.

huin avatar huin commented on June 1, 2024

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.

wichert avatar wichert commented on June 1, 2024

Thanks, this works correctly for me now.

from goupnp.

huin avatar huin commented on June 1, 2024

Excellent, thanks for the confirmation.

from goupnp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.