mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-28 11:44:48 +03:00
Use JsonContent where possible
Should reduce the # of allocated bytes
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Json;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Mime;
|
||||
using System.Text.Json;
|
||||
@@ -32,15 +33,13 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||
|
||||
private Task<HttpResponseMessage> CreateUserByName(HttpClient httpClient, CreateUserByName request)
|
||||
{
|
||||
using var postContent = new ByteArrayContent(JsonSerializer.SerializeToUtf8Bytes(request, _jsonOpions));
|
||||
postContent.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);
|
||||
using var postContent = JsonContent.Create(request, options: _jsonOpions);
|
||||
return httpClient.PostAsync("Users/New", postContent);
|
||||
}
|
||||
|
||||
private Task<HttpResponseMessage> UpdateUserPassword(HttpClient httpClient, Guid userId, UpdateUserPassword request)
|
||||
{
|
||||
using var postContent = new ByteArrayContent(JsonSerializer.SerializeToUtf8Bytes(request, _jsonOpions));
|
||||
postContent.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);
|
||||
using var postContent = JsonContent.Create(request, options: _jsonOpions);
|
||||
return httpClient.PostAsync("Users/" + userId.ToString("N", CultureInfo.InvariantCulture) + "/Password", postContent);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user