I've been attempting to fetch network traffic data from my router via uPnP for use in my skin, and thought I could now use the native WebParser plugin instead of an external command, now that it includes support for custom headers. But alas...
Here's the measure currently:
Code: Select all
[MeasureFritzBox]
Measure=Plugin
Plugin=WebParser
URL=http://192.168.10.1:49000/igdupnp/control/WANCommonIFC1
Header=X-Http-Method-Override:POST
Header2=HOST:192.168.10.1:49000
Header3=SOAPACTION:"urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1#GetAddonInfos"
Header4=Content-Type:text/xml; charset="utf-8"
Header5=Connection:Close
Header6=Content-Length: 300
Header7=Cache-Control:no-cache
Header8=Allow: */*
Header9=#CRLF#
Header10=#XMLData#
UserAgent=" "
ProxyServer=/none
ForceReload=1
DynamicVariables=1
UpdateRate=30
So the two issues are:GET /igdupnp/control/WANCommonIFC1 HTTP/1.1
X-Http-Method-Override: POST
HOST: 192.168.10.1:49000
SOAPACTION: "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1#GetAddonInfos"
Content-Type: text/xml; charset="utf-8"
Content-Length: 300
Cache-Control: no-cache
Allow: */*
<?xml version="1.0" encoding="utf-8"?><s: Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:GetAddonInfos xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1" /></s:Body></s:Envelope>
Connection: Close
- The Connection: Close header is always placed last, no matter which header option you use.
- The Header option adamantly refuses to allow me to place an empty header line.
The only outstanding issue really is ignoring the #CRLF# header. Then it would match perfectly with my VBS script and I could cut out the middleman there.
Usually I just get the output via RunCommand from this:
Code: Select all
On Error Resume Next
host = "192.168.10.1"
If host <> False Then
Set http = Nothing
Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
If http Is Nothing Then Set http = CreateObject("WinHttp.WinHttpRequest.5")
If http Is Nothing Then Set http = CreateObject("WinHttp.WinHttpRequest")
If http Is Nothing Then Set http = CreateObject("MSXML2.ServerXMLHTTP")
If http Is Nothing Then Set http = CreateObject("Microsoft.XMLHTTP")
If http Is Nothing Then
MsgBox "No HTML Object",16,"Error"
Else
body = "<?xml version=""1.0"" encoding=""utf-8""?>" _
& "<s:Envelope xmlns:s=""http://schemas.xmlsoap.org/soap/envelope/"" s:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/"">" _
& "<s:Body><u:GetAddonInfos xmlns:u=""urn:schemas-upnp-org:service:WANIPConnection:1"" /></s:Body></s:Envelope>"
url = "igdupnp/control/WANCommonIFC1"
With http
.Open "POST", "http://" & host & ":49000/" & url,false
.setRequestHeader "Content-Type", "text/xml; charset=""utf-8"""
.setRequestHeader "Connection", "close"
.setRequestHeader "Content-Length", Len(body)
.setRequestHeader "HOST", host & ":49000"
.setRequestHeader "SOAPACTION", """urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1#GetAddonInfos"""
.Send body
End With
WScript.Echo http.responseText
WScript.Quit
End If
End If