diff --git a/server/Handlers/MediaMount_SOAP.cs b/server/Handlers/MediaMount_SOAP.cs index 0a641890..cffbbf35 100644 --- a/server/Handlers/MediaMount_SOAP.cs +++ b/server/Handlers/MediaMount_SOAP.cs @@ -260,12 +260,12 @@ private void Browse_AddItem(IRequest request, XmlDocument result, var res = result.CreateElement(string.Empty, "res", NS_DIDL); res.InnerText = String.Format( - "http://{0}:{1}{2}file/{3}/res", - request.LocalEndPoint.Address, - request.LocalEndPoint.Port, - prefix, - resource.Id - ); + "http://{0}:{1}{2}file/{3}/res", + request.LocalEndPoint.Address, + request.LocalEndPoint.Port, + prefix, + resource.Id + ); var prop = string.Empty; if (props.TryGetValue("SizeRaw", out prop)) { diff --git a/util/HttpStream.cs b/util/HttpStream.cs index 14237603..f933ba5c 100644 --- a/util/HttpStream.cs +++ b/util/HttpStream.cs @@ -8,9 +8,9 @@ namespace NMaier.SimpleDlna.Utilities { public class HttpStream : Stream, IDisposable { - private const int BUFFER_SIZE = 1 << 16; + private const int BUFFER_SIZE = 1 << 10; - private const long SMALL_SEEK = BUFFER_SIZE << 15; + private const long SMALL_SEEK = 1 << 9; private const int TIMEOUT = 30000; @@ -61,12 +61,11 @@ public override bool CanSeek { get { - if (response == null) { - OpenAt(0, HttpMethod.HEAD); - } if (Length <= 0) { return false; } + + EnsureResponse(); var ranges = response.Headers.Get("Accept-Ranges"); if (!string.IsNullOrEmpty(ranges) && ranges.ToUpperInvariant() == "none") { @@ -92,13 +91,18 @@ public override bool CanWrite } } + private void EnsureResponse() + { + if (response != null) { + return; + } + OpenAt(0, HttpMethod.HEAD); + } public string ContentType { get { - if (response == null) { - OpenAt(0, HttpMethod.HEAD); - } + EnsureResponse(); return response.ContentType; } } @@ -107,9 +111,7 @@ public DateTime LastModified { get { - if (response == null) { - OpenAt(0, HttpMethod.HEAD); - } + EnsureResponse(); return response.LastModified; } } @@ -254,6 +256,7 @@ public override void Close() public override void Flush() { + Dispose(true); } public override int Read(byte[] buffer, int offset, int count)