Skip to content

Commit cc7fb1a

Browse files
committed
fix unknown-wire-type
1 parent b6789e4 commit cc7fb1a

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

src/WebApiContrib.Core.Formatter.Protobuf/ProtobufInputFormatter.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ public override async Task<InputFormatterResult> ReadRequestBodyAsync(InputForma
4141

4242
MemoryStream stream = new MemoryStream();
4343
await request.Body.CopyToAsync(stream);
44-
4544
stream.Position = 0;
46-
object result = Model.Deserialize(stream, null, type);
45+
object result = Model.Deserialize(stream, null, type, stream.Length);
4746
return await InputFormatterResult.SuccessAsync(result);
4847
}
4948

src/WebApiContrib.Core.Formatter.Protobuf/ProtobufOutputFormatter.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,10 @@ private static RuntimeTypeModel CreateTypeModel()
4141
public override async Task WriteResponseBodyAsync(OutputFormatterWriteContext context)
4242
{
4343
var response = context.HttpContext.Response;
44-
4544
MemoryStream stream = new MemoryStream();
4645
Model.Serialize(stream, context.Object);
47-
48-
stream.Position = 0;
49-
var sr = new StreamReader(stream);
50-
await response.WriteAsync(sr.ReadToEnd());
46+
var data = stream.ToArray();
47+
await response.Body.WriteAsync(data, 0, data.Length);
5148
}
5249
}
5350
}

src/WebApiContrib.Core.Formatter.Protobuf/WebApiContrib.Core.Formatter.Protobuf.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<PackageId>WebApiContrib.Core.Formatter.Protobuf</PackageId>
1010
<PackageTags>ASP.NET Core;InputFormatter;OutputFormatter;MediaFormatter;Protobuf;Content-Type;aspnetcore</PackageTags>
1111
<PackageProjectUrl>https://github.com/WebAPIContrib/WebAPIContrib.Core/tree/master/src/WebApiContrib.Core.Formatter.Protobuf</PackageProjectUrl>
12-
<Version>2.1.2</Version>
12+
<Version>2.1.3</Version>
1313
</PropertyGroup>
1414

1515
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">

0 commit comments

Comments
 (0)