NickeManarin/ScreenToGif · error · Exception
Unsuccessful download of stream.
Error message
Unsuccessful download of stream.
What it means
Thrown by WebHelper.GetStream when an HTTP GET returns a non-success status code. Unlike the GitHub helper, this method does not include the status code or URL in the message — it simply reports 'Unsuccessful download of stream'. The method is a generic stream downloader used across the application.
Source
Thrown at ScreenToGif.Util/WebHelper.cs:248
throw;
return resp;
}
catch (Exception ex)
{
LogWriter.Log(ex, "Get response: " + url);
}
return null;
}
public static async Task<Stream> GetStream(string url, NameValueCollection headers = null)
{
using var client = GetHttpClient(headers);
var response = await client.GetAsync(url);
if (!response.IsSuccessStatusCode)
throw new Exception("Unsuccessful download of stream.");
return await response.Content.ReadAsStreamAsync();
}
private static HttpWebRequest GetWebRequest(HttpMethod method, string url, NameValueCollection headers = null, string contentType = null, long contentLength = 0)
{
var request = (HttpWebRequest) WebRequest.Create(url);
if (headers != null)
request.Headers.Add(headers);
request.Method = method.ToString();
request.Proxy = GetProxy();
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393";
request.ContentType = contentType;
if (contentLength == 0)View on GitHub (pinned to a4d0a67c21)
Solutions
- Include the URL and status code in the exception message for debugging.
- Log the response.StatusCode and response.ReasonPhrase before throwing.
- Verify the URL is correct and accessible from a browser or curl.
- Ensure required headers (User-Agent, Authorization) are passed via the headers parameter.
Example fix
// before
if (!response.IsSuccessStatusCode)
throw new Exception("Unsuccessful download of stream.");
// after: include URL and status code
if (!response.IsSuccessStatusCode)
throw new HttpRequestException($"Unsuccessful download of stream from '{url}': {(int)response.StatusCode} {response.ReasonPhrase}"); Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-validate URL format and reachability
if (!Uri.TryCreate(url, UriKind.Absolute, out var uri))
throw new ArgumentException($"Invalid URL: {url}");
if (uri.Scheme != Uri.UriSchemeHttp && uri.Scheme != Uri.UriSchemeHttps)
throw new ArgumentException("Only HTTP/HTTPS URLs are supported."); Try / catch
try
{
return await WebHelper.GetStream(url, headers);
}
catch (Exception ex)
{
LogWriter.Log(ex, $"Failed to download stream from {url}");
throw new InvalidOperationException($"Download failed for '{url}': {ex.Message}", ex);
} Prevention
- Always pass a User-Agent header to avoid being blocked by servers.
- Log the URL and HTTP status code when the download fails for easier debugging.
- Validate the URL is well-formed and uses HTTP/HTTPS before calling GetStream.
When it happens
Trigger: client.GetAsync(url) returns a non-2xx response for any URL passed to GetStream. This could be a 404 (resource not found), 403 (forbidden), 500 (server error), or any other error. The URL, headers, or proxy configuration may be wrong.
Common situations: Downloaded resource URL changed or was removed. Proxy or firewall blocks the request. Server requires authentication that wasn't provided. SSL/TLS certificate issue causes a failure. The NameValueCollection headers are missing a required header (e.g., User-Agent).
Related errors
- Empty response from server when getting language codes
- Empty response from server when getting language codes path
- Empty response from server when getting language codes
- Empty response from server when getting language codes path
- Error while trying to get the latest release: {response.Re
AI-assisted analysis of NickeManarin/ScreenToGif@a4d0a67c21 (2026-08-13).
Data as JSON: /api/errors/2eddd139b604e8e8.
Report an issue: GitHub.