Skip to content
This repository
Browse code

Make http streaming work with Win8 client.

  • Loading branch information...
commit a61ee958edcc34a5b7c20ea0a1063f5170a14f03 1 parent 6d17b00
David Fowler authored August 07, 2012
10  SignalR.Client.WinRT/Http/DefaultHttpClient.cs
@@ -14,7 +14,7 @@ public class DefaultHttpClient : IHttpClient
14 14
             var cts = new CancellationTokenSource();
15 15
             var handler = new DefaultHttpHandler(prepareRequest, cts.Cancel);
16 16
             var client = new HttpClient(handler);
17  
-            HttpResponseMessage responseMessage = await client.GetAsync(url, cts.Token);
  17
+            HttpResponseMessage responseMessage = await client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead, cts.Token);
18 18
             return new HttpResponseMessageWrapper(responseMessage);
19 19
         }
20 20
 
@@ -23,18 +23,18 @@ public class DefaultHttpClient : IHttpClient
23 23
             var cts = new CancellationTokenSource();
24 24
             var handler = new DefaultHttpHandler(prepareRequest, cts.Cancel);
25 25
             var client = new HttpClient(handler);
  26
+            var req = new HttpRequestMessage(HttpMethod.Post, url);
26 27
 
27  
-            HttpContent content = null;
28 28
             if (postData == null)
29 29
             {
30  
-                content = new StringContent(String.Empty);
  30
+                req.Content = new StringContent(String.Empty);
31 31
             }
32 32
             else
33 33
             {
34  
-                content = new FormUrlEncodedContent(postData);
  34
+                req.Content = new FormUrlEncodedContent(postData);
35 35
             }
36 36
 
37  
-            HttpResponseMessage responseMessage = await client.PostAsync(url, content, cts.Token);
  37
+            HttpResponseMessage responseMessage = await client.SendAsync(req, HttpCompletionOption.ResponseHeadersRead, cts.Token);
38 38
             return new HttpResponseMessageWrapper(responseMessage);
39 39
         }
40 40
     }
4  SignalR.Client/Connection.cs
@@ -179,12 +179,8 @@ public Task Start()
179 179
         /// <returns>A task that represents when the connection has started.</returns>
180 180
         public Task Start(IHttpClient httpClient)
181 181
         {
182  
-#if NETFX_CORE
183  
-            return Start(new LongPollingTransport(httpClient));
184  
-#else
185 182
             // Pick the best transport supported by the client
186 183
             return Start(new AutoTransport(httpClient));
187  
-#endif
188 184
         }
189 185
 
190 186
         /// <summary>

0 notes on commit a61ee95

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