From 13d3c486a780cfe3d2897941b299938832235584 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 10 Oct 2023 14:54:23 -0400 Subject: [PATCH] - adds a method to specify the content type of the binary request body --- CHANGELOG.md | 6 ++++++ src/Microsoft.Kiota.Abstractions.csproj | 2 +- src/RequestInformation.cs | 11 +++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3de839c..ae43915d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.4.0] - 2023-10-12 + +### Added + +- Added a method to set the request body content type in request information on binary payloads. + ## [1.3.5] - 2023-10-05 ### Changed diff --git a/src/Microsoft.Kiota.Abstractions.csproj b/src/Microsoft.Kiota.Abstractions.csproj index 31466815..64e85afc 100644 --- a/src/Microsoft.Kiota.Abstractions.csproj +++ b/src/Microsoft.Kiota.Abstractions.csproj @@ -14,7 +14,7 @@ https://aka.ms/kiota/docs true true - 1.3.5 + 1.4.0 true false diff --git a/src/RequestInformation.cs b/src/RequestInformation.cs index 70b4ab18..9e08d103 100644 --- a/src/RequestInformation.cs +++ b/src/RequestInformation.cs @@ -190,12 +190,19 @@ public void SetResponseHandler(IResponseHandler responseHandler) /// Sets the request body to a binary stream. /// /// The binary stream to set as a body. - public void SetStreamContent(Stream content) + [Obsolete("Use SetStreamContent and pass the content type instead")] + public void SetStreamContent(Stream content) => SetStreamContent(content, BinaryContentType); + /// + /// Sets the request body to a binary stream. + /// + /// The binary stream to set as a body. + /// The content type to set. + public void SetStreamContent(Stream content, string contentType) { using var activity = _activitySource?.StartActivity(nameof(SetStreamContent)); SetRequestType(content, activity); Content = content; - Headers.TryAdd(ContentTypeHeader, BinaryContentType); + Headers.TryAdd(ContentTypeHeader, contentType); } private static ActivitySource _activitySource = new(typeof(RequestInformation).Namespace!); ///