diff --git a/Frends.HTTP.RequestBytes/CHANGELOG.md b/Frends.HTTP.RequestBytes/CHANGELOG.md
index a401a7b..7236035 100644
--- a/Frends.HTTP.RequestBytes/CHANGELOG.md
+++ b/Frends.HTTP.RequestBytes/CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog
+## [1.1.0] - 2024-08-19
+### Changed
+- Removed handling where only PATCH, PUT, POST and DELETE requests were allowed to have the Content-Type header and content, due to HttpClient failing if e.g., a GET request had content. HttpClient has since been updated to tolerate such requests.
+
## [1.0.1] - 2024-01-17
### Fixed
- Fixed issues which CodeQL found in the codebase.
@@ -7,4 +11,4 @@
## [1.0.0] - 2023-01-27
### Added
-- Initial implementation of Frends.HTTP.Request.
+- Initial implementation of Frends.HTTP.RequestBytes.
diff --git a/Frends.HTTP.RequestBytes/Frends.HTTP.RequestBytes.Tests/UnitTests.cs b/Frends.HTTP.RequestBytes/Frends.HTTP.RequestBytes.Tests/UnitTests.cs
index 295f547..1bbff33 100644
--- a/Frends.HTTP.RequestBytes/Frends.HTTP.RequestBytes.Tests/UnitTests.cs
+++ b/Frends.HTTP.RequestBytes/Frends.HTTP.RequestBytes.Tests/UnitTests.cs
@@ -143,7 +143,29 @@ public async Task RequestTestGetWithParameters()
}
[TestMethod]
- public void RequestShuldThrowExceptionIfOptionIsSet()
+ public async Task RequestTestGetWithContent()
+ {
+ var expectedReturn = Encoding.ASCII.GetBytes("OK");
+
+
+ var contentType = new Header { Name = "Content-Type", Value = "text/plain" };
+ var input = GetInputParams(
+ url: "http://localhost:9191/endpoint",
+ method: Method.GET,
+ headers: new Header[1] { contentType },
+ message: "test"
+ );
+ var options = new Options { ConnectionTimeoutSeconds = 60 };
+
+ _mockHttpMessageHandler.When(input.Url).WithHeaders("Content-Type", "text/plain").WithPartialContent("test")
+ .Respond("application/octet-stream", "OK");
+
+ var result = (dynamic)await HTTP.RequestBytes(input, options, CancellationToken.None);
+ Assert.AreEqual(expectedReturn, result.Body);
+ }
+
+ [TestMethod]
+ public void RequestShouldThrowExceptionIfOptionIsSet()
{
const string expectedReturn = @"'FooBar'";
diff --git a/Frends.HTTP.RequestBytes/Frends.HTTP.RequestBytes/Definitions/SendMethod.cs b/Frends.HTTP.RequestBytes/Frends.HTTP.RequestBytes/Definitions/SendMethod.cs
deleted file mode 100644
index bfb2046..0000000
--- a/Frends.HTTP.RequestBytes/Frends.HTTP.RequestBytes/Definitions/SendMethod.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-namespace Frends.HTTP.RequestBytes.Definitions;
-
-///
-/// Allowed methods for sending content
-///
-public enum SendMethod
-{
- ///
- /// POST Request.
- ///
- POST,
- ///
- /// PUT Request.
- ///
- PUT,
- ///
- /// PATCH Request.
- ///
- PATCH,
- ///
- /// DELETE Request.
- ///
- DELETE
-}
diff --git a/Frends.HTTP.RequestBytes/Frends.HTTP.RequestBytes/Frends.HTTP.RequestBytes.csproj b/Frends.HTTP.RequestBytes/Frends.HTTP.RequestBytes/Frends.HTTP.RequestBytes.csproj
index a98a2fb..5c27912 100644
--- a/Frends.HTTP.RequestBytes/Frends.HTTP.RequestBytes/Frends.HTTP.RequestBytes.csproj
+++ b/Frends.HTTP.RequestBytes/Frends.HTTP.RequestBytes/Frends.HTTP.RequestBytes.csproj
@@ -2,7 +2,7 @@
net6.0
- 1.0.1
+ 1.1.0
Frends
Frends
Frends
diff --git a/Frends.HTTP.RequestBytes/Frends.HTTP.RequestBytes/RequestBytes.cs b/Frends.HTTP.RequestBytes/Frends.HTTP.RequestBytes/RequestBytes.cs
index a8c9432..758040a 100644
--- a/Frends.HTTP.RequestBytes/Frends.HTTP.RequestBytes/RequestBytes.cs
+++ b/Frends.HTTP.RequestBytes/Frends.HTTP.RequestBytes/RequestBytes.cs
@@ -151,12 +151,9 @@ private static async Task GetHttpRequestResponseAsync(
{
cancellationToken.ThrowIfCancellationRequested();
- // Only POST, PUT, PATCH and DELETE can have content, otherwise the HttpClient will fail
- var isContentAllowed = Enum.TryParse(method, ignoreCase: true, result: out SendMethod _);
-
using (var request = new HttpRequestMessage(new HttpMethod(method), new Uri(url))
{
- Content = isContentAllowed ? content : null,
+ Content = content
})
{
@@ -165,7 +162,7 @@ private static async Task GetHttpRequestResponseAsync(
foreach (var header in headers)
{
var requestHeaderAddedSuccessfully = request.Headers.TryAddWithoutValidation(header.Key, header.Value);
- if (!requestHeaderAddedSuccessfully && request.Content != null)
+ if (!requestHeaderAddedSuccessfully)
{
//Could not add to request headers try to add to content headers
// this check is probably not needed anymore as the new HttpClient does not seem fail on malformed headers