Skip to content

Commit

Permalink
Improve Steam Store error handling
Browse files Browse the repository at this point in the history
Malformed escape pair at index 33: index.php?area=package&SubId=469&%output_params%&l=english
  • Loading branch information
mvegter committed Jul 18, 2021
1 parent 142c272 commit 7747ff9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Depressurizer.Core/Models/DatabaseEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -474,14 474,15 @@ public void ScrapeStore(string steamWebApi, string languageCode)

private static HttpWebRequest GetSteamRequest(string url)
{
HttpWebRequest req = (HttpWebRequest) WebRequest.Create(url);
HttpWebRequest req = WebRequest.CreateHttp(url);
// Cookie bypasses the age gate
req.CookieContainer = new CookieContainer(3);
req.CookieContainer.Add(new Cookie("birthtime", "-473392799", "/", "store.steampowered.com"));
req.CookieContainer.Add(new Cookie("mature_content", "1", "/", "store.steampowered.com"));
req.CookieContainer.Add(new Cookie("lastagecheckage", "1-January-1955", "/", "store.steampowered.com"));
// Cookies get discarded on automatic redirects so we have to follow them manually
req.AllowAutoRedirect = false;
req.Timeout = 10_000;
return req;
}

Expand Down Expand Up @@ -792,6 793,12 @@ private AppType ScrapeStoreHelper(string languageCode)
Logger.Verbose("Scraping {0}: Redirected to a different id: {1}.", AppId, redirectTarget);
}
}
catch (UriFormatException e)
{
Logger.Warn("Scraping {0}: Caught an UriFormatException most likely something on Steam side is wrong; {1}.", AppId, e);
resp?.Dispose();
return AppType.Unknown;
}
catch (WebException e) when (e.Status == WebExceptionStatus.Timeout)
{
Logger.Warn("Scraping {0}: Exception thrown while reading page - operation timed out (page no longer exists or internet connection interrupted?); {1}.", AppId, e);
Expand Down

0 comments on commit 7747ff9

Please sign in to comment.