Skip to content
This repository
Browse code

Use the HttpClient stack in silverlight.

  • Loading branch information...
commit b51a4144dba794e8f8ce3242d48799037055eb80 1 parent 6b869a4
David Fowler authored July 22, 2012

Showing 1 changed file with 11 additions and 2 deletions. Show diff stats Hide diff stats

  1. 13  SignalR.Client/Http/HttpHelper.cs
13  SignalR.Client/Http/HttpHelper.cs
@@ -43,7 +43,7 @@ public static Task<HttpWebResponse> GetAsync(string url)
43 43
 
44 44
         public static Task<HttpWebResponse> GetAsync(string url, Action<HttpWebRequest> requestPreparer)
45 45
         {
46  
-            var request = (HttpWebRequest)HttpWebRequest.Create(url);
  46
+            HttpWebRequest request = CreateWebRequest(url);
47 47
             if (requestPreparer != null)
48 48
             {
49 49
                 requestPreparer(request);
@@ -100,7 +100,7 @@ public static string ReadAsString(this HttpWebResponse response)
100 100
 
101 101
         private static Task<HttpWebResponse> PostInternal(string url, Action<HttpWebRequest> requestPreparer, IDictionary<string, string> postData)
102 102
         {
103  
-            var request = (HttpWebRequest)HttpWebRequest.Create(url);
  103
+            HttpWebRequest request = CreateWebRequest(url);
104 104
 
105 105
             if (requestPreparer != null)
106 106
             {
@@ -153,5 +153,14 @@ private static byte[] ProcessPostData(IDictionary<string, string> postData)
153 153
 
154 154
             return Encoding.UTF8.GetBytes(sb.ToString());
155 155
         }
  156
+
  157
+        private static HttpWebRequest CreateWebRequest(string url)
  158
+        {
  159
+#if !SILVERLIGHT || WINDOWS_PHONE
  160
+            return (HttpWebRequest)WebRequest.Create(url);
  161
+#else
  162
+            return (HttpWebRequest)System.Net.Browser.WebRequestCreator.ClientHttp.Create(new Uri(url));
  163
+#endif
  164
+        }
156 165
     }
157 166
 }

0 notes on commit b51a414

Please sign in to comment.
Something went wrong with that request. Please try again.