Merge pull request #2971 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2017-10-23 02:06:37 -04:00 committed by GitHub
commit 3129feee75
10 changed files with 66 additions and 19 deletions

View File

@ -33,7 +33,7 @@ namespace Emby.Dlna.ContentDirectory
{ {
CancellationToken = cancellationToken, CancellationToken = cancellationToken,
UserAgent = "Emby", UserAgent = "Emby",
RequestContentType = "text/xml; charset=\"utf-8\"", RequestContentType = "text/xml",
LogErrorResponseBody = true, LogErrorResponseBody = true,
Url = request.ContentDirectoryUrl, Url = request.ContentDirectoryUrl,
BufferContent = false BufferContent = false

View File

@ -72,7 +72,10 @@ namespace Emby.Dlna.PlayTo
Url = url, Url = url,
UserAgent = USERAGENT, UserAgent = USERAGENT,
LogErrorResponseBody = true, LogErrorResponseBody = true,
BufferContent = false BufferContent = false,
// The periodic requests may keep some devices awake
LogRequestAsDebug = true
}; };
options.RequestHeaders["HOST"] = ip + ":" + port.ToString(_usCulture); options.RequestHeaders["HOST"] = ip + ":" + port.ToString(_usCulture);
@ -93,7 +96,10 @@ namespace Emby.Dlna.PlayTo
Url = url, Url = url,
UserAgent = USERAGENT, UserAgent = USERAGENT,
LogErrorResponseBody = true, LogErrorResponseBody = true,
BufferContent = false BufferContent = false,
// The periodic requests may keep some devices awake
LogRequestAsDebug = true
}; };
options.RequestHeaders["FriendlyName.DLNA.ORG"] = FriendlyName; options.RequestHeaders["FriendlyName.DLNA.ORG"] = FriendlyName;
@ -125,7 +131,10 @@ namespace Emby.Dlna.PlayTo
UserAgent = USERAGENT, UserAgent = USERAGENT,
LogRequest = logRequest || _config.GetDlnaConfiguration().EnableDebugLog, LogRequest = logRequest || _config.GetDlnaConfiguration().EnableDebugLog,
LogErrorResponseBody = true, LogErrorResponseBody = true,
BufferContent = false BufferContent = false,
// The periodic requests may keep some devices awake
LogRequestAsDebug = true
}; };
options.RequestHeaders["SOAPAction"] = soapAction; options.RequestHeaders["SOAPAction"] = soapAction;
@ -137,7 +146,8 @@ namespace Emby.Dlna.PlayTo
options.RequestHeaders["contentFeatures.dlna.org"] = header; options.RequestHeaders["contentFeatures.dlna.org"] = header;
} }
options.RequestContentType = "text/xml; charset=\"utf-8\""; options.RequestContentType = "text/xml";
options.AppendCharsetToMimeType = true;
options.RequestContent = postData; options.RequestContent = postData;
return _httpClient.Post(options); return _httpClient.Post(options);

View File

@ -461,7 +461,7 @@ namespace Emby.Drawing
}; };
} }
var path = item.Path; var path = info.Path;
_logger.Info("Getting image size for item {0} {1}", item.GetType().Name, path); _logger.Info("Getting image size for item {0} {1}", item.GetType().Name, path);
var size = GetImageSize(path, allowSlowMethods); var size = GetImageSize(path, allowSlowMethods);

View File

@ -1655,9 +1655,9 @@ namespace Emby.Server.Implementations.Dto
return null; return null;
} }
} }
catch catch (Exception ex)
{ {
//_logger.ErrorException("Failed to determine primary image aspect ratio for {0}", ex, path); //_logger.ErrorException("Failed to determine primary image aspect ratio for {0}", ex, imageInfo.Path);
return null; return null;
} }
} }

View File

@ -320,8 +320,6 @@ namespace Emby.Server.Implementations.HttpClientManager
private async Task<HttpResponseInfo> GetCachedResponse(string responseCachePath, TimeSpan cacheLength, string url) private async Task<HttpResponseInfo> GetCachedResponse(string responseCachePath, TimeSpan cacheLength, string url)
{ {
_logger.Info("Checking for cache file {0}", responseCachePath);
try try
{ {
if (_fileSystem.GetLastWriteTimeUtc(responseCachePath).Add(cacheLength) > DateTime.UtcNow) if (_fileSystem.GetLastWriteTimeUtc(responseCachePath).Add(cacheLength) > DateTime.UtcNow)
@ -399,10 +397,19 @@ namespace Emby.Server.Implementations.HttpClientManager
{ {
try try
{ {
var bytes = options.RequestContentBytes ?? // TODO: We can always put this in the options object if needed
Encoding.UTF8.GetBytes(options.RequestContent ?? string.Empty); var requestEncoding = Encoding.UTF8;
httpWebRequest.ContentType = options.RequestContentType ?? "application/x-www-form-urlencoded"; var bytes = options.RequestContentBytes ?? requestEncoding.GetBytes(options.RequestContent ?? string.Empty);
var contentType = options.RequestContentType ?? "application/x-www-form-urlencoded";
if (options.AppendCharsetToMimeType)
{
contentType = contentType.TrimEnd(';') + "; charset=\"utf-8\"";
}
httpWebRequest.ContentType = contentType;
httpWebRequest.ContentLength = bytes.Length; httpWebRequest.ContentLength = bytes.Length;
(await httpWebRequest.GetRequestStreamAsync().ConfigureAwait(false)).Write(bytes, 0, bytes.Length); (await httpWebRequest.GetRequestStreamAsync().ConfigureAwait(false)).Write(bytes, 0, bytes.Length);
@ -430,7 +437,14 @@ namespace Emby.Server.Implementations.HttpClientManager
if (options.LogRequest) if (options.LogRequest)
{ {
_logger.Info("HttpClientManager {0}: {1}", httpMethod.ToUpper(), options.Url); if (options.LogRequestAsDebug)
{
_logger.Debug("HttpClientManager {0}: {1}", httpMethod.ToUpper(), options.Url);
}
else
{
_logger.Info("HttpClientManager {0}: {1}", httpMethod.ToUpper(), options.Url);
}
} }
try try
@ -597,7 +611,14 @@ namespace Emby.Server.Implementations.HttpClientManager
if (options.LogRequest) if (options.LogRequest)
{ {
_logger.Info("HttpClientManager.GetTempFileResponse url: {0}", options.Url); if (options.LogRequestAsDebug)
{
_logger.Debug("HttpClientManager.GetTempFileResponse url: {0}", options.Url);
}
else
{
_logger.Info("HttpClientManager.GetTempFileResponse url: {0}", options.Url);
}
} }
var client = GetHttpClient(GetHostFromUrl(options.Url), options.EnableHttpCompression); var client = GetHttpClient(GetHostFromUrl(options.Url), options.EnableHttpCompression);

View File

@ -30,8 +30,11 @@ namespace Emby.Server.Implementations.Library.Resolvers
// Must be an image file within a photo collection // Must be an image file within a photo collection
if (args.IsDirectory) if (args.IsDirectory)
{ {
if (string.Equals(args.GetCollectionType(), CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase) || // Must be an image file within a photo collection
string.Equals(args.GetCollectionType(), CollectionType.Photos, StringComparison.OrdinalIgnoreCase)) var collectionType = args.GetCollectionType();
if (string.Equals(collectionType, CollectionType.Photos, StringComparison.OrdinalIgnoreCase) ||
(string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase) && args.GetLibraryOptions().EnablePhotos))
{ {
if (HasPhotos(args)) if (HasPhotos(args))
{ {

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Threading; using System.Threading;
using System.Text;
namespace MediaBrowser.Common.Net namespace MediaBrowser.Common.Net
{ {
@ -90,6 +91,7 @@ namespace MediaBrowser.Common.Net
public bool BufferContent { get; set; } public bool BufferContent { get; set; }
public bool LogRequest { get; set; } public bool LogRequest { get; set; }
public bool LogRequestAsDebug { get; set; }
public bool LogErrors { get; set; } public bool LogErrors { get; set; }
public bool LogErrorResponseBody { get; set; } public bool LogErrorResponseBody { get; set; }
@ -102,6 +104,8 @@ namespace MediaBrowser.Common.Net
public bool PreferIpv4 { get; set; } public bool PreferIpv4 { get; set; }
public bool EnableDefaultUserAgent { get; set; } public bool EnableDefaultUserAgent { get; set; }
public bool AppendCharsetToMimeType { get; set; }
private string GetHeaderValue(string name) private string GetHeaderValue(string name)
{ {
string value; string value;

View File

@ -64,6 +64,10 @@ namespace Mono.Nat.Upnp
{ {
var req = new HttpRequestOptions(); var req = new HttpRequestOptions();
// The periodic request logging may keep some devices awake
req.LogRequestAsDebug = true;
req.LogErrors = false;
req.Url = "http://" + this.hostAddress.ToString() + this.servicesDescriptionUrl; req.Url = "http://" + this.hostAddress.ToString() + this.servicesDescriptionUrl;
req.RequestHeaders.Add("ACCEPT-LANGUAGE", "en"); req.RequestHeaders.Add("ACCEPT-LANGUAGE", "en");

View File

@ -52,9 +52,14 @@ namespace Mono.Nat.Upnp
var req = new HttpRequestOptions(); var req = new HttpRequestOptions();
req.LogErrors = false; req.LogErrors = false;
// The periodic request logging may keep some devices awake
req.LogRequestAsDebug = true;
req.Url = ss; req.Url = ss;
req.EnableKeepAlive = false; req.EnableKeepAlive = false;
req.RequestContentType = "text/xml; charset=\"utf-8\""; req.RequestContentType = "text/xml";
req.AppendCharsetToMimeType = true;
req.RequestHeaders.Add("SOAPACTION", "\"" + device.ServiceType + "#" + upnpMethod + "\""); req.RequestHeaders.Add("SOAPACTION", "\"" + device.ServiceType + "#" + upnpMethod + "\"");
string bodyString = "<s:Envelope " string bodyString = "<s:Envelope "

View File

@ -1,3 +1,3 @@
using System.Reflection; using System.Reflection;
[assembly: AssemblyVersion("3.2.33.18")] [assembly: AssemblyVersion("3.2.33.19")]