More swarm fixes.

- Fix client routing again.
- Swap X-Powered-By for User-Agent in clients
- Set Accept header to application/json.
This commit is contained in:
Cyberboss
2020-12-27 17:43:59 -05:00
parent 975ed3dee4
commit ff20c9bbc9
2 changed files with 8 additions and 6 deletions
@@ -17,8 +17,6 @@ namespace Tgstation.Server.Host.Extensions
/// </summary>
static class ApplicationBuilderExtensions
{
public const string XPoweredByHeader = "X-Powered-By";
/// <summary>
/// Gets a <see cref="ILogger"/> from a given <paramref name="httpContext"/>
/// </summary>
@@ -131,7 +129,7 @@ namespace Tgstation.Server.Host.Extensions
applicationBuilder.Use(async (context, next) =>
{
context.Response.Headers.Add(XPoweredByHeader, assemblyInformationProvider.VersionPrefix);
context.Response.Headers.Add("X-Powered-By", assemblyInformationProvider.VersionPrefix);
await next().ConfigureAwait(false);
});
}
@@ -7,13 +7,14 @@ using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Mime;
using System.Threading;
using System.Threading.Tasks;
using Tgstation.Server.Api.Models;
using Tgstation.Server.Host.Configuration;
using Tgstation.Server.Host.Core;
using Tgstation.Server.Host.Database;
using Tgstation.Server.Host.Extensions;
using Tgstation.Server.Host.Extensions.Converters;
using Tgstation.Server.Host.System;
@@ -846,10 +847,13 @@ namespace Tgstation.Server.Host.Swarm
var request = new HttpRequestMessage(
httpMethod,
swarmServer.Address + subroute);
swarmServer.Address + subroute.Substring(1));
request.Headers.Add(SwarmConstants.ApiKeyHeader, swarmConfiguration.PrivateKey);
request.Headers.Add(ApplicationBuilderExtensions.XPoweredByHeader, assemblyInformationProvider.VersionPrefix);
request.Headers.UserAgent.Clear();
request.Headers.UserAgent.Add(assemblyInformationProvider.ProductInfoHeaderValue);
request.Headers.Accept.Clear();
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(MediaTypeNames.Application.Json));
if (registrationIdOverride.HasValue)
request.Headers.Add(SwarmConstants.RegistrationIdHeader, registrationIdOverride.Value.ToString());
else if (swarmController)