-
-
Save davidglassborow/cc59afa45df6dd79160fb5aff706b0e4 to your computer and use it in GitHub Desktop.
C# http long polling example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var url = "http://localhost:8082/consumers/my_binary_consumer/instances/my_instance/topics/test"; | |
using (var client = new HttpClient()) | |
{ | |
client.Timeout = TimeSpan.FromMilliseconds(Timeout.Infinite); | |
var request = new HttpRequestMessage(HttpMethod.Get, url); | |
using (var response = await client.SendAsync( | |
request, | |
HttpCompletionOption.ResponseHeadersRead)) | |
{ | |
using (var body = await response.Content.ReadAsStreamAsync()) | |
using (var reader = new StreamReader(body)) | |
while (!reader.EndOfStream) | |
Console.WriteLine(reader.ReadLine()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment