Skip to content

Commit 8267c1c

Browse files
committed
Manually merge PR. Closes #621
Thanks!
1 parent 8d4277e commit 8267c1c

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

PushSharp.Windows/WnsConnection.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Linq;
1010
using System.Net;
1111
using System.Text;
12+
using System.IO;
1213

1314
namespace PushSharp.Windows
1415
{
@@ -89,11 +90,17 @@ public async Task Send (WnsNotification notification)
8990
http.DefaultRequestHeaders.Add("X-WNS-Cache-Policy", winTileBadge.CachePolicy == WnsNotificationCachePolicyType.Cache ? "cache" : "no-cache");
9091
}
9192

92-
var content = new StringContent (
93-
notification.Payload.ToString (), // Get XML payload
94-
System.Text.Encoding.UTF8,
95-
notification.Type == WnsNotificationType.Raw ? "application/octet-stream" : "text/xml");
96-
93+
HttpContent content = null;
94+
95+
if (notification.Type == WnsNotificationType.Raw) {
96+
content = new StreamContent (new MemoryStream (Encoding.UTF8.GetBytes (notification.Payload.ToString())));
97+
} else {
98+
content = new StringContent(
99+
notification.Payload.ToString(), // Get XML payload
100+
Encoding.UTF8,
101+
"text/xml");
102+
}
103+
97104
var result = await http.PostAsync (notification.ChannelUri, content);
98105

99106
var status = ParseStatus (result, notification);

0 commit comments

Comments
 (0)