Files
UnrealEngineUWP/Engine/Source/Programs/AutomationTool/Gauntlet/Framework/Utils/Gauntlet.HttpRequest.cs
tim kennedy c6b7cbaccb #JIRA: none
#preflight 63fe91f8ae54ee4ce9e7a51a
** Had to do a new CL because of the move rules preventing me from submitting the previous CL**

So that the new Gauntlet RPC tools do not go out to licensees prematurely, moving all RPC related files to:

FortniteGame/Build/Scripts/Automation/Utility/RPC/Gauntlet/Framework/
FortniteGame/Build/Scripts/Automation/Utility/RPC/Gauntlet/Framework/Utils
FortniteGame/Build/Scripts/Automation/Utility/RPC/Gauntlet/Framework/Utils/RPC

This preserves Gauntlet's file structure, meaning that if we decide to make this available to license holders, we can simply move the contents of the Gauntlet folder into the Gauntlet project and the structure will be compatible. There are two classes that needed a file created to be moved - GauntletHttpClient and GauntletHttpResponse - they are now in Gauntlet.GauntletHttpClient.cs

[CL 24465068 by tim kennedy in ue5-main branch]
2023-03-01 12:35:09 -05:00

55 lines
1.5 KiB
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using System;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using AutomationTool;
namespace Gauntlet
{
public static class HttpRequest
{
public static AuthenticationHeaderValue Authentication(string Target, string Token)
{
return new AuthenticationHeaderValue(Target, Token);
}
public class Connection
{
private HttpClient Client;
public Connection(string Server, AuthenticationHeaderValue Auth)
{
Client = new HttpClient();
Client.BaseAddress = new Uri(Server);
if (Auth == null)
{
throw new AutomationException(string.Format("Missing Authorization Header for {0}", Server));
}
Client.DefaultRequestHeaders.Authorization = Auth;
}
public HttpResponse PostJson(string Path, string JsonString)
{
HttpRequestMessage Request = new HttpRequestMessage(HttpMethod.Post, Path);
Request.Content = new StringContent(JsonString, Encoding.UTF8, "application/json");
using (HttpResponseMessage Response = Client.SendAsync(Request).Result)
{
return new HttpResponse(Response.StatusCode, Response.Content.ReadAsStringAsync().Result);
}
}
}
public class HttpResponse
{
public string Content;
public HttpStatusCode StatusCode;
public HttpResponse(HttpStatusCode InCode, string InContent)
{
StatusCode = InCode;
Content = InContent;
}
public bool IsSuccessStatusCode { get { return StatusCode == HttpStatusCode.OK; } }
}
}
}