Merge pull request #4510 from crobibero/http-accept-header
Set default request accept headers
This commit is contained in:
commit
da96cbaf78
|
@ -63,10 +63,16 @@ namespace Jellyfin.Server
|
|||
var productHeader = new ProductInfoHeaderValue(
|
||||
_serverApplicationHost.Name.Replace(' ', '-'),
|
||||
_serverApplicationHost.ApplicationVersionString);
|
||||
var acceptJsonHeader = new MediaTypeWithQualityHeaderValue(MediaTypeNames.Application.Json, 1.0);
|
||||
var acceptXmlHeader = new MediaTypeWithQualityHeaderValue(MediaTypeNames.Application.Xml, 0.9);
|
||||
var acceptAnyHeader = new MediaTypeWithQualityHeaderValue("*/*", 0.8);
|
||||
services
|
||||
.AddHttpClient(NamedClient.Default, c =>
|
||||
{
|
||||
c.DefaultRequestHeaders.UserAgent.Add(productHeader);
|
||||
c.DefaultRequestHeaders.Accept.Add(acceptJsonHeader);
|
||||
c.DefaultRequestHeaders.Accept.Add(acceptXmlHeader);
|
||||
c.DefaultRequestHeaders.Accept.Add(acceptAnyHeader);
|
||||
})
|
||||
.ConfigurePrimaryHttpMessageHandler(x => new DefaultHttpClientHandler());
|
||||
|
||||
|
@ -74,6 +80,8 @@ namespace Jellyfin.Server
|
|||
{
|
||||
c.DefaultRequestHeaders.UserAgent.Add(productHeader);
|
||||
c.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue($"({_serverApplicationHost.ApplicationUserAgentAddress})"));
|
||||
c.DefaultRequestHeaders.Accept.Add(acceptJsonHeader);
|
||||
c.DefaultRequestHeaders.Accept.Add(acceptAnyHeader);
|
||||
})
|
||||
.ConfigurePrimaryHttpMessageHandler(x => new DefaultHttpClientHandler());
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user