aboutsummaryrefslogtreecommitdiff
path: root/Mono.Nat/Upnp/Messages/UpnpMessage.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Mono.Nat/Upnp/Messages/UpnpMessage.cs')
-rw-r--r--Mono.Nat/Upnp/Messages/UpnpMessage.cs49
1 files changed, 17 insertions, 32 deletions
diff --git a/Mono.Nat/Upnp/Messages/UpnpMessage.cs b/Mono.Nat/Upnp/Messages/UpnpMessage.cs
index 1151dd997..d47241d4a 100644
--- a/Mono.Nat/Upnp/Messages/UpnpMessage.cs
+++ b/Mono.Nat/Upnp/Messages/UpnpMessage.cs
@@ -24,13 +24,8 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
-using System.Diagnostics;
using System.Xml;
-using System.Net;
-using System.IO;
using System.Text;
-using System.Globalization;
using MediaBrowser.Common.Net;
namespace Mono.Nat.Upnp
@@ -46,41 +41,31 @@ namespace Mono.Nat.Upnp
protected HttpRequestOptions CreateRequest(string upnpMethod, string methodParameters)
{
- string ss = "http://" + this.device.HostEndPoint.ToString() + this.device.ControlUrl;
+ var req = new HttpRequestOptions()
+ {
+ Url = $"http://{this.device.HostEndPoint}{this.device.ControlUrl}",
+ EnableKeepAlive = false,
+ RequestContentType = "text/xml",
+ RequestContent = "<s:Envelope "
+ + "xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" "
+ + "s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
+ + "<s:Body>"
+ + "<u:" + upnpMethod + " "
+ + "xmlns:u=\"" + device.ServiceType + "\">"
+ + methodParameters
+ + "</u:" + upnpMethod + ">"
+ + "</s:Body>"
+ + "</s:Envelope>\r\n\r\n"
+ };
- var req = new HttpRequestOptions();
- req.LogErrors = false;
-
- // The periodic request logging may keep some devices awake
- req.LogRequestAsDebug = true;
-
- req.Url = ss;
- req.EnableKeepAlive = false;
- req.RequestContentType = "text/xml";
- req.AppendCharsetToMimeType = true;
req.RequestHeaders.Add("SOAPACTION", "\"" + device.ServiceType + "#" + upnpMethod + "\"");
- string bodyString = "<s:Envelope "
- + "xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" "
- + "s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
- + "<s:Body>"
- + "<u:" + upnpMethod + " "
- + "xmlns:u=\"" + device.ServiceType + "\">"
- + methodParameters
- + "</u:" + upnpMethod + ">"
- + "</s:Body>"
- + "</s:Envelope>\r\n\r\n";
-
- req.RequestContentBytes = System.Text.Encoding.UTF8.GetBytes(bodyString);
return req;
}
public abstract HttpRequestOptions Encode();
- public virtual string Method
- {
- get { return "POST"; }
- }
+ public virtual string Method => "POST";
protected void WriteFullElement(XmlWriter writer, string element, string value)
{