Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nmaier committed Jun 18, 2016
1 parent 68ea1e8 commit 975b095
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
12 changes: 6 additions & 6 deletions server/Handlers/MediaMount_SOAP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
25 changes: 14 additions & 11 deletions util/HttpStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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") {
Expand All @@ -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;
}
}
Expand All @@ -107,9 +111,7 @@ public DateTime LastModified
{
get
{
if (response == null) {
OpenAt(0, HttpMethod.HEAD);
}
EnsureResponse();
return response.LastModified;
}
}
Expand Down Expand Up @@ -254,6 +256,7 @@ public override void Close()

public override void Flush()
{
Dispose(true);
}

public override int Read(byte[] buffer, int offset, int count)
Expand Down

0 comments on commit 975b095

Please sign in to comment.