Skip to content

Commit

Permalink
#221 fixed http response headers (mono exception)
Browse files Browse the repository at this point in the history
  • Loading branch information
yar229 committed Aug 26, 2021
1 parent 5f4ce96 commit 4a866a7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions NWebDav/NWebDav.Server/Helpers/ResponseHelpers.cs
Expand Up @@ -73,6 +73,12 @@ public static async Task SendResponseAsync(this IHttpResponse response, DavStatu
// Set the response
response.SetStatus(statusCode);

// YaR: mono require headers be set before writing to response
// Set content type/length
response.SetHeaderValue("Content-Type", "text/xml; charset=\"utf-8\"");
// Since we has no memory stream, can't get length... but still working
//response.SetHeaderValue("Content-Length", response.Stream.Length.ToString(CultureInfo.InvariantCulture)); // Position.ToString(CultureInfo.InvariantCulture));

// Obtain the result as an XML document
using (var xmlWriter = XmlWriter.Create(response.Stream, new XmlWriterSettings
{
Expand Down Expand Up @@ -102,11 +108,6 @@ public static async Task SendResponseAsync(this IHttpResponse response, DavStatu
xDocument.WriteTo(xmlWriter);
#endif
}

// Set content type/length
response.SetHeaderValue("Content-Type", "text/xml; charset=\"utf-8\"");
// Since we has no memory stream, can't get length... but still working
//response.SetHeaderValue("Content-Length", response.Stream.Length.ToString(CultureInfo.InvariantCulture)); // Position.ToString(CultureInfo.InvariantCulture));
}
}
}

0 comments on commit 4a866a7

Please sign in to comment.