mirror of
https://github.com/ppy/osu
synced 2024-12-16 11:56:31 +00:00
Fix json web requests having incorrect user agents (#7549)
Fix json web requests having incorrect user agents
This commit is contained in:
commit
b30e268238
@ -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>
|
||||
|
@ -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;
|
||||
|
||||
|
21
osu.Game/Online/API/OsuJsonWebRequest.cs
Normal file
21
osu.Game/Online/API/OsuJsonWebRequest.cs
Normal 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!";
|
||||
}
|
||||
}
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user