Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit a080405

Browse files
committed
override GetResponse for Silverlight
1 parent f9df838 commit a080405

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/ServiceStack.Text/PclExport.Sl5.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
using System.Linq;
1010
using System.Net;
1111
using System.Reflection;
12+
using System.Threading;
13+
using System.Threading.Tasks;
1214

1315
namespace ServiceStack
1416
{
@@ -64,7 +66,7 @@ public override void Config(HttpWebRequest req,
6466

6567
//Methods others than GET and POST are only supported by Client request creator, see
6668
//http://msdn.microsoft.com/en-us/library/cc838250(v=vs.95).aspx
67-
if (req.GetType().Name != "BrowserHttpWebRequest") return;
69+
if (!IsBrowserHttp(req)) return;
6870
if (req.Method != "GET" && req.Method != "POST")
6971
{
7072
req.Headers[HttpHeaders.XHttpMethodOverride] = req.Method;
@@ -80,6 +82,19 @@ public override HttpWebRequest CreateWebRequest(string requestUri, bool? emulate
8082

8183
return (HttpWebRequest)creator.Create(new Uri(requestUri));
8284
}
85+
86+
private static bool IsBrowserHttp(WebRequest req)
87+
{
88+
return req.GetType().Name == "BrowserHttpWebRequest";
89+
}
90+
91+
public override WebResponse GetResponse(WebRequest webRequest)
92+
{
93+
var task = webRequest.GetResponseAsync();
94+
task.Wait();
95+
var webRes = task.Result;
96+
return webRes;
97+
}
8398
}
8499
}
85100

0 commit comments

Comments
 (0)