diff --git a/ArchiSteamFarm/IPC/Controllers/Api/WWWController.cs b/ArchiSteamFarm/IPC/Controllers/Api/WWWController.cs index 40411103d..e34f81933 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/WWWController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/WWWController.cs @@ -25,7 +25,6 @@ using System.Collections.Immutable; using System.Globalization; using System.Net; using System.Threading.Tasks; -using ArchiSteamFarm.IPC.Requests; using ArchiSteamFarm.IPC.Responses; using ArchiSteamFarm.Localization; using Microsoft.AspNetCore.Mvc; @@ -127,37 +126,5 @@ namespace ArchiSteamFarm.IPC.Controllers.Api { return releaseResponse != null ? Ok(new GenericResponse(new GitHubReleaseResponse(releaseResponse))) : StatusCode((int) HttpStatusCode.ServiceUnavailable, new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, WebBrowser.MaxTries))); } - - /// - /// Sends a HTTPS request through ASF's built-in HttpClient. - /// - /// - /// This is internal API being utilizied by our ASF-ui IPC frontend. You should not depend on existence of any /Api/WWW endpoints as they can disappear and change anytime. - /// - [Consumes("application/json")] - [HttpPost("Send")] - [Obsolete("ASF-ui should switch to new /Api/WWW/Github/{Release|Wiki} endpoints.")] - [ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)] - [ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] - [ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.ServiceUnavailable)] - public async Task> SendPost([FromBody] WWWSendRequest request) { - if (request == null) { - throw new ArgumentNullException(nameof(request)); - } - - if (ASF.WebBrowser == null) { - throw new InvalidOperationException(nameof(ASF.WebBrowser)); - } - - ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningDeprecated, nameof(SendPost), nameof(GitHubReleaseGet) + "/" + nameof(GitHubWikiHistoryGet) + "/" + nameof(GitHubWikiPageGet))); - - if (string.IsNullOrEmpty(request.URL) || !Uri.TryCreate(request.URL, UriKind.Absolute, out Uri? uri) || !uri.Scheme.Equals(Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase)) { - return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(request.URL)))); - } - - WebBrowser.StringResponse? urlResponse = await ASF.WebBrowser.UrlGetToString(request.URL!).ConfigureAwait(false); - - return urlResponse != null ? Ok(new GenericResponse(urlResponse.Content)) : StatusCode((int) HttpStatusCode.ServiceUnavailable, new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorRequestFailedTooManyTimes, WebBrowser.MaxTries))); - } } } diff --git a/ArchiSteamFarm/IPC/Requests/WWWSendRequest.cs b/ArchiSteamFarm/IPC/Requests/WWWSendRequest.cs deleted file mode 100644 index 3c9d8a990..000000000 --- a/ArchiSteamFarm/IPC/Requests/WWWSendRequest.cs +++ /dev/null @@ -1,42 +0,0 @@ -// _ _ _ ____ _ _____ -// / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___ -// / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \ -// / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | | -// /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_| -// | -// Copyright 2015-2021 Ɓukasz "JustArchi" Domeradzki -// Contact: JustArchi@JustArchi.net -// | -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// | -// http://www.apache.org/licenses/LICENSE-2.0 -// | -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.ComponentModel.DataAnnotations; -using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; - -namespace ArchiSteamFarm.IPC.Requests { - [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] - public sealed class WWWSendRequest { - /// - /// Full URL of the request to be made. - /// - /// - /// URL must start from https:// scheme. - /// - [Required] - [JsonProperty(Required = Required.Always)] - public string URL { get; private set; } = ""; - - [JsonConstructor] - private WWWSendRequest() { } - } -}