Fix json web requests having incorrect user agents (#7549)

Fix json web requests having incorrect user agents
This commit is contained in:
Dean Herbert 2020-01-17 22:08:43 +09:00 committed by GitHub
commit b30e268238
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 15 deletions

View File

@ -16,7 +16,7 @@ namespace osu.Game.Online.API
{
protected override WebRequest CreateWebRequest() => new OsuJsonWebRequest<T>(Uri);
public T Result => ((JsonWebRequest<T>)WebRequest).ResponseObject;
public T Result => ((OsuJsonWebRequest<T>)WebRequest).ResponseObject;
protected APIRequest()
{
@ -30,16 +30,6 @@ namespace osu.Game.Online.API
/// This will be scheduled to the API's internal scheduler (run on update thread automatically).
/// </summary>
public new event APISuccessHandler<T> Success;
private class OsuJsonWebRequest<U> : JsonWebRequest<U>
{
public OsuJsonWebRequest(string uri)
: base(uri)
{
}
protected override string UserAgent => "osu!";
}
}
/// <summary>

View File

@ -4,7 +4,6 @@
using System.Diagnostics;
using System.Net.Http;
using osu.Framework.Bindables;
using osu.Framework.IO.Network;
namespace osu.Game.Online.API
{
@ -166,7 +165,7 @@ namespace osu.Game.Online.API
}
}
private class AccessTokenRequest : JsonWebRequest<OAuthToken>
private class AccessTokenRequest : OsuJsonWebRequest<OAuthToken>
{
protected string GrantType;

View File

@ -0,0 +1,21 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.IO.Network;
namespace osu.Game.Online.API
{
public class OsuJsonWebRequest<T> : JsonWebRequest<T>
{
public OsuJsonWebRequest(string uri)
: base(uri)
{
}
public OsuJsonWebRequest()
{
}
protected override string UserAgent => "osu!";
}
}

View File

@ -7,8 +7,8 @@ using Newtonsoft.Json;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using osu.Framework.IO.Network;
using osu.Framework.Platform;
using osu.Game.Online.API;
using osu.Game.Overlays.Notifications;
namespace osu.Game.Updater
@ -36,7 +36,7 @@ namespace osu.Game.Updater
{
try
{
var releases = new JsonWebRequest<GitHubRelease>("https://api.github.com/repos/ppy/osu/releases/latest");
var releases = new OsuJsonWebRequest<GitHubRelease>("https://api.github.com/repos/ppy/osu/releases/latest");
await releases.PerformAsync();