Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use the HttpClient stack in silverlight.

  • Loading branch information...
commit b51a4144dba794e8f8ce3242d48799037055eb80 1 parent 6b869a4
@davidfowl davidfowl authored
Showing with 11 additions and 2 deletions.
  1. +11 −2 SignalR.Client/Http/HttpHelper.cs
View
13 SignalR.Client/Http/HttpHelper.cs
@@ -43,7 +43,7 @@ public static Task<HttpWebResponse> GetAsync(string url)
public static Task<HttpWebResponse> GetAsync(string url, Action<HttpWebRequest> requestPreparer)
{
- var request = (HttpWebRequest)HttpWebRequest.Create(url);
+ HttpWebRequest request = CreateWebRequest(url);
if (requestPreparer != null)
{
requestPreparer(request);
@@ -100,7 +100,7 @@ public static string ReadAsString(this HttpWebResponse response)
private static Task<HttpWebResponse> PostInternal(string url, Action<HttpWebRequest> requestPreparer, IDictionary<string, string> postData)
{
- var request = (HttpWebRequest)HttpWebRequest.Create(url);
+ HttpWebRequest request = CreateWebRequest(url);
if (requestPreparer != null)
{
@@ -153,5 +153,14 @@ private static byte[] ProcessPostData(IDictionary<string, string> postData)
return Encoding.UTF8.GetBytes(sb.ToString());
}
+
+ private static HttpWebRequest CreateWebRequest(string url)
+ {
+#if !SILVERLIGHT || WINDOWS_PHONE
+ return (HttpWebRequest)WebRequest.Create(url);
+#else
+ return (HttpWebRequest)System.Net.Browser.WebRequestCreator.ClientHttp.Create(new Uri(url));
+#endif
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.