-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1060 from azasp/issue/Content-length-mismatch-too…
…-many-bytes-written Fix: Content length mismatch : too many bytes written
- Loading branch information
Showing
1 changed file
with
19 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,3 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Net.Http.Headers; | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Security.Authentication; | ||
using System.ServiceModel; | ||
using System.ServiceModel.Channels; | ||
using System.Threading.Tasks; | ||
using System.Xml; | ||
using Microsoft.AspNetCore.Connections; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Http.Features; | ||
|
@@ -26,6 +12,20 @@ | |
using SoapCore.MessageEncoder; | ||
using SoapCore.Meta; | ||
using SoapCore.ServiceModel; | ||
using System; | ||
Check warning on line 15 in src/SoapCore/SoapEndpointMiddleware.cs GitHub Actions / Analyze
|
||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Net.Http.Headers; | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Security.Authentication; | ||
using System.ServiceModel; | ||
using System.ServiceModel.Channels; | ||
using System.Threading.Tasks; | ||
using System.Xml; | ||
|
||
namespace SoapCore | ||
{ | ||
|
@@ -265,7 +265,10 @@ private async Task ProcessMeta(HttpContext httpContext, bool showDocumentation) | |
await messageEncoder.WriteMessageAsync(responseMessage, httpContext, ms, _options.IndentWsdl); | ||
ms.Position = 0; | ||
var documentation = SoapDefinition.DeserializeFromStream(ms).GenerateDocumentation(); | ||
|
||
if (httpContext?.Response.ContentLength <= documentation.Length) | ||
{ | ||
httpContext.Response.ContentLength = documentation.Length; | ||
} | ||
await httpContext.Response.WriteAsync(documentation); | ||
|
||
return; | ||
|
@@ -956,7 +959,7 @@ private Message CreateErrorResponseMessage( | |
private void SetHttpResponse(HttpContext httpContext, Message message) | ||
{ | ||
if (!message.Properties.TryGetValue(HttpResponseMessageProperty.Name, out var value) | ||
|| !(value is HttpResponseMessageProperty httpProperty)) | ||
|| value is not HttpResponseMessageProperty httpProperty) | ||
{ | ||
return; | ||
} | ||
|