mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-05 15:28:28 +01:00
Use JsonContent where possible
Should reduce the # of allocated bytes
This commit is contained in:
@@ -2,6 +2,7 @@ using System;
|
||||
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;
|
||||
@@ -62,8 +63,7 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||
Name = "ThisProfileDoesNotExist"
|
||||
};
|
||||
|
||||
using var content = new ByteArrayContent(JsonSerializer.SerializeToUtf8Bytes(deviceProfile, _jsonOptions));
|
||||
content.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);
|
||||
using var content = JsonContent.Create(deviceProfile, options: _jsonOptions);
|
||||
using var getResponse = await client.PostAsync("/Dlna/Profiles/" + NonExistentProfile, content).ConfigureAwait(false);
|
||||
Assert.Equal(HttpStatusCode.NotFound, getResponse.StatusCode);
|
||||
}
|
||||
@@ -80,8 +80,7 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||
Name = "ThisProfileIsNew"
|
||||
};
|
||||
|
||||
using var content = new ByteArrayContent(JsonSerializer.SerializeToUtf8Bytes(deviceProfile, _jsonOptions));
|
||||
content.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);
|
||||
using var content = JsonContent.Create(deviceProfile, options: _jsonOptions);
|
||||
using var getResponse = await client.PostAsync("/Dlna/Profiles", content).ConfigureAwait(false);
|
||||
Assert.Equal(HttpStatusCode.NoContent, getResponse.StatusCode);
|
||||
}
|
||||
@@ -120,8 +119,7 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||
Id = _newDeviceProfileId
|
||||
};
|
||||
|
||||
using var content = new ByteArrayContent(JsonSerializer.SerializeToUtf8Bytes(updatedProfile, _jsonOptions));
|
||||
content.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);
|
||||
using var content = JsonContent.Create(updatedProfile, options: _jsonOptions);
|
||||
using var getResponse = await client.PostAsync("/Dlna/Profiles", content).ConfigureAwait(false);
|
||||
Assert.Equal(HttpStatusCode.NoContent, getResponse.StatusCode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user