/// <summary> /// Gets the response stream async from the url /// </summary> /// <param name="url">url to request from</param> /// <returns>return a string in the encoding specified</returns> /// <exception cref="RequestException">Throw this exception if any error occurs</exception> public async Task<StreamAndHeaders> GetResponseStreamAsync(Uri url) { var client = System.Net.WebRequest.CreateHttp(url); var response = new StreamAndHeaders(); client.Method = "GET"; response.SetRequestHeaders(client.Headers); var webresponse = await client.GetResponseAsync(); response.Stream = webresponse.GetResponseStream(); return response; }
/// <summary> /// Gets the response stream async from the url /// </summary> /// <param name="url">url to request from</param> /// <returns>return a string in the encoding specified</returns> /// <exception cref="RequestException">Throw this exception if any error occurs</exception> public async Task<StreamAndHeaders> GetResponseStreamAsync(Uri url) { var client = WebRequest.Create(url); var response = new StreamAndHeaders(); client.Method = "GET"; response.SetRequestHeaders(client.Headers); var webresponse = client.GetResponseAsync(); await webresponse.WaitWithTimeoutAsync(Timeout); response.Stream = webresponse.Result.GetResponseStream(); return response; }
/// <summary> /// Gets the response stream async from the url /// </summary> /// <param name="url">url to request from</param> /// <returns>return a string in the encoding specified</returns> public async Task<StreamAndHeaders> GetResponseStreamAsync(Uri url) { var client = WebRequest.Create(url); var response = new StreamAndHeaders(); client.Method = "GET"; response.SetRequestHeaders(client.Headers); client.Timeout = Timeout; var webresponse = await client.GetResponseAsync(); response.Stream = webresponse.GetResponseStream(); response.SetResponseHeaders(webresponse.Headers); return response; }
/// <summary> /// Gets the response stream from the url /// </summary> /// <param name="url">url to request from</param> /// <returns>return a string in the encoding specified</returns> public StreamAndHeaders GetResponseStream(Uri url) { var client = WebRequest.Create(url); var response = new StreamAndHeaders(); client.Method = "GET"; response.SetRequestHeaders(client.Headers); client.Timeout = Timeout; var webresponse = client.GetResponse(); response.Stream = webresponse.GetResponseStream(); response.SetResponseHeaders(webresponse.Headers); return response; }
/// <summary> /// Gets the response stream from the url /// </summary> /// <param name="url">url to request from</param> /// <returns>return a string in the encoding specified</returns> /// <exception cref="RequestException">Throw this exception if any error occurs</exception> public StreamAndHeaders GetResponseStream(Uri url) { var client = System.Net.WebRequest.CreateHttp(url); var response = new StreamAndHeaders(); client.Method = "GET"; response.SetRequestHeaders(client.Headers); var webresponse = client.GetResponseAsync(); webresponse.WaitWithTimeout(Timeout); response.Stream = webresponse.Result.GetResponseStream(); return response; }
/// <summary> /// Gets the response string async from the url /// </summary> /// <param name="url">url to request from</param> /// <returns>return a string in the encoding specified</returns> /// <exception cref="RequestException">Throw this exception if any error occurs</exception> public StreamAndHeaders GetResponseStream(Uri url) { var client = WebRequest.CreateHttp(url); var response = new StreamAndHeaders(); if (GzipEnabled) { client.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip; } client.Method = "GET"; client.Timeout = Timeout; response.SetRequestHeaders(client.Headers); var webresponse = client.GetResponse(); response.Stream = webresponse.GetResponseStream(); response.SetResponseHeaders(webresponse.Headers); return response; }