Skip to content

Commit

Permalink
- adds a method to specify the content type of the binary request body
Browse files Browse the repository at this point in the history
  • Loading branch information
baywet committed Oct 10, 2023
1 parent ea0782a commit 13d3c48
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Kiota.Abstractions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageProjectUrl>https://aka.ms/kiota/docs</PackageProjectUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<Deterministic>true</Deterministic>
<VersionPrefix>1.3.5</VersionPrefix>
<VersionPrefix>1.4.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<SignAssembly>false</SignAssembly>
Expand Down
11 changes: 9 additions & 2 deletions src/RequestInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,19 @@ public void SetResponseHandler(IResponseHandler responseHandler)
/// Sets the request body to a binary stream.
/// </summary>
/// <param name="content">The binary stream to set as a body.</param>
public void SetStreamContent(Stream content)
[Obsolete("Use SetStreamContent and pass the content type instead")]

Check warning on line 193 in src/RequestInformation.cs

View workflow job for this annotation

GitHub Actions / Build

Do not forget to remove this deprecated code someday. (https://rules.sonarsource.com/csharp/RSPEC-1133)

Check warning on line 193 in src/RequestInformation.cs

View workflow job for this annotation

GitHub Actions / Build

Do not forget to remove this deprecated code someday. (https://rules.sonarsource.com/csharp/RSPEC-1133)

Check warning on line 193 in src/RequestInformation.cs

View workflow job for this annotation

GitHub Actions / Build

Do not forget to remove this deprecated code someday. (https://rules.sonarsource.com/csharp/RSPEC-1133)

Check warning on line 193 in src/RequestInformation.cs

View workflow job for this annotation

GitHub Actions / Build

Do not forget to remove this deprecated code someday. (https://rules.sonarsource.com/csharp/RSPEC-1133)
public void SetStreamContent(Stream content) => SetStreamContent(content, BinaryContentType);
/// <summary>
/// Sets the request body to a binary stream.
/// </summary>
/// <param name="content">The binary stream to set as a body.</param>
/// <param name="contentType">The content type to set.</param>
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!);
/// <summary>
Expand Down

0 comments on commit 13d3c48

Please sign in to comment.