You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#preflight 627030f2592316675c21b2d7 #rb Geoff.Evans,Chris.Constantinescu [CL 20764203 by Jerome Delattre in ue5-main branch]
54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
using System;
|
|
using System.Net;
|
|
using System.Text;
|
|
using System.Net.Http;
|
|
using System.Net.Http.Headers;
|
|
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; } }
|
|
}
|
|
}
|
|
} |