mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 03:26:07 +02:00
Merge pull request #6929 from Bond-009/jsoncontent
This commit is contained in:
commit
b1025121b8
7 changed files with 21 additions and 39 deletions
|
@ -9,6 +9,7 @@ using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Net.Http.Json;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Net.Mime;
|
using System.Net.Mime;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
@ -101,11 +102,10 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var requestString = JsonSerializer.Serialize(requestList, _jsonOptions);
|
_logger.LogDebug("Request string for schedules is: {@RequestString}", requestList);
|
||||||
_logger.LogDebug("Request string for schedules is: {RequestString}", requestString);
|
|
||||||
|
|
||||||
using var options = new HttpRequestMessage(HttpMethod.Post, ApiUrl + "/schedules");
|
using var options = new HttpRequestMessage(HttpMethod.Post, ApiUrl + "/schedules");
|
||||||
options.Content = new StringContent(requestString, Encoding.UTF8, MediaTypeNames.Application.Json);
|
options.Content = JsonContent.Create(requestList, options: _jsonOptions);
|
||||||
options.Headers.TryAddWithoutValidation("token", token);
|
options.Headers.TryAddWithoutValidation("token", token);
|
||||||
using var response = await Send(options, true, info, cancellationToken).ConfigureAwait(false);
|
using var response = await Send(options, true, info, cancellationToken).ConfigureAwait(false);
|
||||||
await using var responseStream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
await using var responseStream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
@ -121,8 +121,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||||
programRequestOptions.Headers.TryAddWithoutValidation("token", token);
|
programRequestOptions.Headers.TryAddWithoutValidation("token", token);
|
||||||
|
|
||||||
var programIds = dailySchedules.SelectMany(d => d.Programs.Select(s => s.ProgramId)).Distinct();
|
var programIds = dailySchedules.SelectMany(d => d.Programs.Select(s => s.ProgramId)).Distinct();
|
||||||
programRequestOptions.Content = new ByteArrayContent(JsonSerializer.SerializeToUtf8Bytes(programIds, _jsonOptions));
|
programRequestOptions.Content = JsonContent.Create(programIds, options: _jsonOptions);
|
||||||
programRequestOptions.Content.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);
|
|
||||||
|
|
||||||
using var innerResponse = await Send(programRequestOptions, true, info, cancellationToken).ConfigureAwait(false);
|
using var innerResponse = await Send(programRequestOptions, true, info, cancellationToken).ConfigureAwait(false);
|
||||||
await using var innerResponseStream = await innerResponse.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
await using var innerResponseStream = await innerResponse.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
|
@ -81,6 +81,7 @@ namespace MediaBrowser.Model.Configuration
|
||||||
public bool RequirePerfectSubtitleMatch { get; set; }
|
public bool RequirePerfectSubtitleMatch { get; set; }
|
||||||
|
|
||||||
public bool SaveSubtitlesWithMedia { get; set; }
|
public bool SaveSubtitlesWithMedia { get; set; }
|
||||||
|
|
||||||
public bool AutomaticallyAddToCollection { get; set; }
|
public bool AutomaticallyAddToCollection { get; set; }
|
||||||
|
|
||||||
public TypeOptions[] TypeOptions { get; set; }
|
public TypeOptions[] TypeOptions { get; set; }
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Net.Http.Json;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Net.Mime;
|
using System.Net.Mime;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
@ -26,14 +27,13 @@ namespace Jellyfin.Server.Integration.Tests
|
||||||
using var completeResponse = await client.PostAsync("/Startup/Complete", new ByteArrayContent(Array.Empty<byte>())).ConfigureAwait(false);
|
using var completeResponse = await client.PostAsync("/Startup/Complete", new ByteArrayContent(Array.Empty<byte>())).ConfigureAwait(false);
|
||||||
Assert.Equal(HttpStatusCode.NoContent, completeResponse.StatusCode);
|
Assert.Equal(HttpStatusCode.NoContent, completeResponse.StatusCode);
|
||||||
|
|
||||||
using var content = new ByteArrayContent(JsonSerializer.SerializeToUtf8Bytes(
|
using var content = JsonContent.Create(
|
||||||
new AuthenticateUserByName()
|
new AuthenticateUserByName()
|
||||||
{
|
{
|
||||||
Username = user!.Name,
|
Username = user!.Name,
|
||||||
Pw = user.Password,
|
Pw = user.Password,
|
||||||
},
|
},
|
||||||
jsonOptions));
|
options: jsonOptions);
|
||||||
content.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);
|
|
||||||
content.Headers.Add("X-Emby-Authorization", DummyAuthHeader);
|
content.Headers.Add("X-Emby-Authorization", DummyAuthHeader);
|
||||||
|
|
||||||
using var authResponse = await client.PostAsync("/Users/AuthenticateByName", content).ConfigureAwait(false);
|
using var authResponse = await client.PostAsync("/Users/AuthenticateByName", content).ConfigureAwait(false);
|
||||||
|
|
|
@ -2,6 +2,7 @@ using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Net.Http.Json;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Net.Mime;
|
using System.Net.Mime;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -62,9 +63,7 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
Name = "ThisProfileDoesNotExist"
|
Name = "ThisProfileDoesNotExist"
|
||||||
};
|
};
|
||||||
|
|
||||||
using var content = new ByteArrayContent(JsonSerializer.SerializeToUtf8Bytes(deviceProfile, _jsonOptions));
|
using var getResponse = await client.PostAsJsonAsync("/Dlna/Profiles/" + NonExistentProfile, deviceProfile, _jsonOptions).ConfigureAwait(false);
|
||||||
content.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);
|
|
||||||
using var getResponse = await client.PostAsync("/Dlna/Profiles/" + NonExistentProfile, content).ConfigureAwait(false);
|
|
||||||
Assert.Equal(HttpStatusCode.NotFound, getResponse.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, getResponse.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,9 +79,7 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
Name = "ThisProfileIsNew"
|
Name = "ThisProfileIsNew"
|
||||||
};
|
};
|
||||||
|
|
||||||
using var content = new ByteArrayContent(JsonSerializer.SerializeToUtf8Bytes(deviceProfile, _jsonOptions));
|
using var getResponse = await client.PostAsJsonAsync("/Dlna/Profiles", deviceProfile, _jsonOptions).ConfigureAwait(false);
|
||||||
content.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);
|
|
||||||
using var getResponse = await client.PostAsync("/Dlna/Profiles", content).ConfigureAwait(false);
|
|
||||||
Assert.Equal(HttpStatusCode.NoContent, getResponse.StatusCode);
|
Assert.Equal(HttpStatusCode.NoContent, getResponse.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,9 +117,7 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
Id = _newDeviceProfileId
|
Id = _newDeviceProfileId
|
||||||
};
|
};
|
||||||
|
|
||||||
using var content = new ByteArrayContent(JsonSerializer.SerializeToUtf8Bytes(updatedProfile, _jsonOptions));
|
using var getResponse = await client.PostAsJsonAsync("/Dlna/Profiles", updatedProfile, _jsonOptions).ConfigureAwait(false);
|
||||||
content.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);
|
|
||||||
using var getResponse = await client.PostAsync("/Dlna/Profiles", content).ConfigureAwait(false);
|
|
||||||
Assert.Equal(HttpStatusCode.NoContent, getResponse.StatusCode);
|
Assert.Equal(HttpStatusCode.NoContent, getResponse.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Net.Http.Json;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Net.Mime;
|
using System.Net.Mime;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
@ -71,9 +72,7 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
Path = "/this/path/doesnt/exist"
|
Path = "/this/path/doesnt/exist"
|
||||||
};
|
};
|
||||||
|
|
||||||
using var postContent = new ByteArrayContent(JsonSerializer.SerializeToUtf8Bytes(data, _jsonOptions));
|
var response = await client.PostAsJsonAsync("Library/VirtualFolders/Paths", data, _jsonOptions).ConfigureAwait(false);
|
||||||
postContent.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);
|
|
||||||
var response = await client.PostAsync("Library/VirtualFolders/Paths", postContent).ConfigureAwait(false);
|
|
||||||
|
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
@ -90,9 +89,7 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
PathInfo = new MediaPathInfo("test")
|
PathInfo = new MediaPathInfo("test")
|
||||||
};
|
};
|
||||||
|
|
||||||
using var postContent = new ByteArrayContent(JsonSerializer.SerializeToUtf8Bytes(data, _jsonOptions));
|
var response = await client.PostAsJsonAsync("Library/VirtualFolders/Paths/Update", data, _jsonOptions).ConfigureAwait(false);
|
||||||
postContent.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);
|
|
||||||
var response = await client.PostAsync("Library/VirtualFolders/Paths/Update", postContent).ConfigureAwait(false);
|
|
||||||
|
|
||||||
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Net.Http.Json;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Net.Mime;
|
using System.Net.Mime;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
@ -36,9 +37,7 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
PreferredMetadataLanguage = "nl"
|
PreferredMetadataLanguage = "nl"
|
||||||
};
|
};
|
||||||
|
|
||||||
using var postContent = new ByteArrayContent(JsonSerializer.SerializeToUtf8Bytes(config, _jsonOptions));
|
using var postResponse = await client.PostAsJsonAsync("/Startup/Configuration", config, _jsonOptions).ConfigureAwait(false);
|
||||||
postContent.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);
|
|
||||||
using var postResponse = await client.PostAsync("/Startup/Configuration", postContent).ConfigureAwait(false);
|
|
||||||
Assert.Equal(HttpStatusCode.NoContent, postResponse.StatusCode);
|
Assert.Equal(HttpStatusCode.NoContent, postResponse.StatusCode);
|
||||||
|
|
||||||
using var getResponse = await client.GetAsync("/Startup/Configuration").ConfigureAwait(false);
|
using var getResponse = await client.GetAsync("/Startup/Configuration").ConfigureAwait(false);
|
||||||
|
@ -80,9 +79,7 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
Password = "NewPassword"
|
Password = "NewPassword"
|
||||||
};
|
};
|
||||||
|
|
||||||
using var postContent = new ByteArrayContent(JsonSerializer.SerializeToUtf8Bytes(user, _jsonOptions));
|
var postResponse = await client.PostAsJsonAsync("/Startup/User", user, _jsonOptions).ConfigureAwait(false);
|
||||||
postContent.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);
|
|
||||||
var postResponse = await client.PostAsync("/Startup/User", postContent).ConfigureAwait(false);
|
|
||||||
Assert.Equal(HttpStatusCode.NoContent, postResponse.StatusCode);
|
Assert.Equal(HttpStatusCode.NoContent, postResponse.StatusCode);
|
||||||
|
|
||||||
var getResponse = await client.GetAsync("/Startup/User").ConfigureAwait(false);
|
var getResponse = await client.GetAsync("/Startup/User").ConfigureAwait(false);
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Net.Http.Json;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Net.Mime;
|
using System.Net.Mime;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
@ -31,18 +32,10 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task<HttpResponseMessage> CreateUserByName(HttpClient httpClient, CreateUserByName request)
|
private Task<HttpResponseMessage> CreateUserByName(HttpClient httpClient, CreateUserByName request)
|
||||||
{
|
=> httpClient.PostAsJsonAsync("Users/New", request, _jsonOpions);
|
||||||
using var postContent = new ByteArrayContent(JsonSerializer.SerializeToUtf8Bytes(request, _jsonOpions));
|
|
||||||
postContent.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);
|
|
||||||
return httpClient.PostAsync("Users/New", postContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Task<HttpResponseMessage> UpdateUserPassword(HttpClient httpClient, Guid userId, UpdateUserPassword request)
|
private Task<HttpResponseMessage> UpdateUserPassword(HttpClient httpClient, Guid userId, UpdateUserPassword request)
|
||||||
{
|
=> httpClient.PostAsJsonAsync("Users/" + userId.ToString("N", CultureInfo.InvariantCulture) + "/Password", request, _jsonOpions);
|
||||||
using var postContent = new ByteArrayContent(JsonSerializer.SerializeToUtf8Bytes(request, _jsonOpions));
|
|
||||||
postContent.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);
|
|
||||||
return httpClient.PostAsync("Users/" + userId.ToString("N", CultureInfo.InvariantCulture) + "/Password", postContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[Priority(-1)]
|
[Priority(-1)]
|
||||||
|
|
Loading…
Reference in a new issue