mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Fix json web requests having incorrect user agents
This commit is contained in:
@ -16,7 +16,7 @@ namespace osu.Game.Online.API
|
|||||||
{
|
{
|
||||||
protected override WebRequest CreateWebRequest() => new OsuJsonWebRequest<T>(Uri);
|
protected override WebRequest CreateWebRequest() => new OsuJsonWebRequest<T>(Uri);
|
||||||
|
|
||||||
public T Result => ((JsonWebRequest<T>)WebRequest).ResponseObject;
|
public T Result => ((OsuJsonWebRequest<T>)WebRequest).ResponseObject;
|
||||||
|
|
||||||
protected APIRequest()
|
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).
|
/// This will be scheduled to the API's internal scheduler (run on update thread automatically).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public new event APISuccessHandler<T> Success;
|
public new event APISuccessHandler<T> Success;
|
||||||
|
|
||||||
private class OsuJsonWebRequest<U> : JsonWebRequest<U>
|
|
||||||
{
|
|
||||||
public OsuJsonWebRequest(string uri)
|
|
||||||
: base(uri)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override string UserAgent => "osu!";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.IO.Network;
|
|
||||||
|
|
||||||
namespace osu.Game.Online.API
|
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;
|
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;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.IO.Network;
|
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Overlays.Notifications;
|
using osu.Game.Overlays.Notifications;
|
||||||
|
|
||||||
namespace osu.Game.Updater
|
namespace osu.Game.Updater
|
||||||
@ -36,7 +36,7 @@ namespace osu.Game.Updater
|
|||||||
{
|
{
|
||||||
try
|
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();
|
await releases.PerformAsync();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user