diff --git a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs index 3ac8c7ac4..74e5df1e9 100644 --- a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs +++ b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs @@ -167,7 +167,9 @@ namespace ImageProcessor.Web.HttpModules private async Task ProcessImageAsync(HttpContext context) { HttpRequest request = context.Request; - bool isRemote = request.Path.Equals(RemotePrefix, StringComparison.OrdinalIgnoreCase); + + // Fixes issue 10. + bool isRemote = request.Path.EndsWith(RemotePrefix, StringComparison.OrdinalIgnoreCase); string requestPath = string.Empty; string queryString = string.Empty; @@ -176,8 +178,14 @@ namespace ImageProcessor.Web.HttpModules // We need to split the querystring to get the actual values we want. string urlDecode = HttpUtility.UrlDecode(request.QueryString.ToString()); - if (urlDecode != null) + if (!string.IsNullOrWhiteSpace(urlDecode)) { + // UrlDecode seems to mess up in some circumstance. + if (urlDecode.IndexOf("://", StringComparison.OrdinalIgnoreCase) == -1) + { + urlDecode = urlDecode.Replace(":/", "://"); + } + string[] paths = urlDecode.Split('?'); requestPath = paths[0]; diff --git a/src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs b/src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs index 76e54af35..210cf2a6c 100644 --- a/src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs +++ b/src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("2.3.0.0")] -[assembly: AssemblyFileVersion("2.3.0.0")] +[assembly: AssemblyVersion("2.3.0.1")] +[assembly: AssemblyFileVersion("2.3.0.1")] diff --git a/src/Nuget/ImageProcessor.Web.2.3.0.1.nupkg.REMOVED.git-id b/src/Nuget/ImageProcessor.Web.2.3.0.1.nupkg.REMOVED.git-id new file mode 100644 index 000000000..71aa309d9 --- /dev/null +++ b/src/Nuget/ImageProcessor.Web.2.3.0.1.nupkg.REMOVED.git-id @@ -0,0 +1 @@ +8a839fc32a168bcddd1bd9043d64e9502bab4e99 \ No newline at end of file diff --git a/src/packages/sqlite-net.1.0.7/content/SQLite.cs.REMOVED.git-id b/src/packages/sqlite-net.1.0.7/content/SQLite.cs.REMOVED.git-id index a32267d93..2dfc5c248 100644 --- a/src/packages/sqlite-net.1.0.7/content/SQLite.cs.REMOVED.git-id +++ b/src/packages/sqlite-net.1.0.7/content/SQLite.cs.REMOVED.git-id @@ -1 +1 @@ -86139d135bd91c43d8ffe8808f0f04975fd22a82 \ No newline at end of file +d2856e3733eb6c7d85057c37ae415e54c8bf2386 \ No newline at end of file diff --git a/src/packages/sqlite-net.1.0.7/content/SQLiteAsync.cs b/src/packages/sqlite-net.1.0.7/content/SQLiteAsync.cs index 48e064476..b4cf34e07 100644 --- a/src/packages/sqlite-net.1.0.7/content/SQLiteAsync.cs +++ b/src/packages/sqlite-net.1.0.7/content/SQLiteAsync.cs @@ -30,126 +30,115 @@ using System.Threading.Tasks; namespace SQLite { - public partial class SQLiteAsyncConnection - { - SQLiteConnectionString _connectionString; - - public SQLiteAsyncConnection(string databasePath, bool storeDateTimeAsTicks = false) - { - _connectionString = new SQLiteConnectionString(databasePath, storeDateTimeAsTicks); - } - - SQLiteConnectionWithLock GetConnection() - { - return SQLiteConnectionPool.Shared.GetConnection(_connectionString); - } - - public Task CreateTableAsync() - where T : new() - { - return CreateTablesAsync(typeof(T)); - } - - public Task CreateTablesAsync() - where T : new() - where T2 : new() - { - return CreateTablesAsync(typeof(T), typeof(T2)); - } - - public Task CreateTablesAsync() - where T : new() - where T2 : new() - where T3 : new() - { - return CreateTablesAsync(typeof(T), typeof(T2), typeof(T3)); - } - - public Task CreateTablesAsync() - where T : new() - where T2 : new() - where T3 : new() - where T4 : new() - { - return CreateTablesAsync(typeof(T), typeof(T2), typeof(T3), typeof(T4)); - } - - public Task CreateTablesAsync() - where T : new() - where T2 : new() - where T3 : new() - where T4 : new() - where T5 : new() - { - return CreateTablesAsync(typeof(T), typeof(T2), typeof(T3), typeof(T4), typeof(T5)); - } - - public Task CreateTablesAsync(params Type[] types) - { - return Task.Factory.StartNew(() => - { - CreateTablesResult result = new CreateTablesResult(); - var conn = GetConnection(); - using (conn.Lock()) - { - foreach (Type type in types) - { - int aResult = conn.CreateTable(type); - result.Results[type] = aResult; - } - } - return result; - }); - } - - public Task DropTableAsync() - where T : new() - { - return Task.Factory.StartNew(() => - { - var conn = GetConnection(); - using (conn.Lock()) - { - return conn.DropTable(); - } - }); - } - - public Task InsertAsync(object item) - { - return Task.Factory.StartNew(() => - { - var conn = GetConnection(); - using (conn.Lock()) - { - return conn.Insert(item); - } - }); - } - - public Task UpdateAsync(object item) - { - return Task.Factory.StartNew(() => - { - var conn = GetConnection(); - using (conn.Lock()) - { - return conn.Update(item); - } - }); - } - - public Task DeleteAsync(object item) - { - return Task.Factory.StartNew(() => - { - var conn = GetConnection(); - using (conn.Lock()) - { - return conn.Delete(item); - } - }); - } + public partial class SQLiteAsyncConnection + { + SQLiteConnectionString _connectionString; + + public SQLiteAsyncConnection (string databasePath, bool storeDateTimeAsTicks = false) + { + _connectionString = new SQLiteConnectionString (databasePath, storeDateTimeAsTicks); + } + + SQLiteConnectionWithLock GetConnection () + { + return SQLiteConnectionPool.Shared.GetConnection (_connectionString); + } + + public Task CreateTableAsync () + where T : new () + { + return CreateTablesAsync (typeof (T)); + } + + public Task CreateTablesAsync () + where T : new () + where T2 : new () + { + return CreateTablesAsync (typeof (T), typeof (T2)); + } + + public Task CreateTablesAsync () + where T : new () + where T2 : new () + where T3 : new () + { + return CreateTablesAsync (typeof (T), typeof (T2), typeof (T3)); + } + + public Task CreateTablesAsync () + where T : new () + where T2 : new () + where T3 : new () + where T4 : new () + { + return CreateTablesAsync (typeof (T), typeof (T2), typeof (T3), typeof (T4)); + } + + public Task CreateTablesAsync () + where T : new () + where T2 : new () + where T3 : new () + where T4 : new () + where T5 : new () + { + return CreateTablesAsync (typeof (T), typeof (T2), typeof (T3), typeof (T4), typeof (T5)); + } + + public Task CreateTablesAsync (params Type[] types) + { + return Task.Factory.StartNew (() => { + CreateTablesResult result = new CreateTablesResult (); + var conn = GetConnection (); + using (conn.Lock ()) { + foreach (Type type in types) { + int aResult = conn.CreateTable (type); + result.Results[type] = aResult; + } + } + return result; + }); + } + + public Task DropTableAsync () + where T : new () + { + return Task.Factory.StartNew (() => { + var conn = GetConnection (); + using (conn.Lock ()) { + return conn.DropTable (); + } + }); + } + + public Task InsertAsync (object item) + { + return Task.Factory.StartNew (() => { + var conn = GetConnection (); + using (conn.Lock ()) { + return conn.Insert (item); + } + }); + } + + public Task UpdateAsync (object item) + { + return Task.Factory.StartNew (() => { + var conn = GetConnection (); + using (conn.Lock ()) { + return conn.Update (item); + } + }); + } + + public Task DeleteAsync (object item) + { + return Task.Factory.StartNew (() => { + var conn = GetConnection (); + using (conn.Lock ()) { + return conn.Delete (item); + } + }); + } public Task GetAsync(object pk) where T : new() @@ -164,20 +153,18 @@ namespace SQLite }); } - public Task FindAsync(object pk) - where T : new() - { - return Task.Factory.StartNew(() => - { - var conn = GetConnection(); - using (conn.Lock()) - { - return conn.Find(pk); - } - }); - } - - public Task GetAsync(Expression> predicate) + public Task FindAsync (object pk) + where T : new () + { + return Task.Factory.StartNew (() => { + var conn = GetConnection (); + using (conn.Lock ()) { + return conn.Find (pk); + } + }); + } + + public Task GetAsync (Expression> predicate) where T : new() { return Task.Factory.StartNew(() => @@ -185,70 +172,60 @@ namespace SQLite var conn = GetConnection(); using (conn.Lock()) { - return conn.Get(predicate); + return conn.Get (predicate); } }); } - public Task FindAsync(Expression> predicate) - where T : new() - { - return Task.Factory.StartNew(() => - { - var conn = GetConnection(); - using (conn.Lock()) - { - return conn.Find(predicate); - } - }); - } - - public Task ExecuteAsync(string query, params object[] args) - { - return Task.Factory.StartNew(() => - { - var conn = GetConnection(); - using (conn.Lock()) - { - return conn.Execute(query, args); - } - }); - } - - public Task InsertAllAsync(IEnumerable items) - { - return Task.Factory.StartNew(() => - { - var conn = GetConnection(); - using (conn.Lock()) - { - return conn.InsertAll(items); - } - }); - } + public Task FindAsync (Expression> predicate) + where T : new () + { + return Task.Factory.StartNew (() => { + var conn = GetConnection (); + using (conn.Lock ()) { + return conn.Find (predicate); + } + }); + } + + public Task ExecuteAsync (string query, params object[] args) + { + return Task.Factory.StartNew (() => { + var conn = GetConnection (); + using (conn.Lock ()) { + return conn.Execute (query, args); + } + }); + } + + public Task InsertAllAsync (IEnumerable items) + { + return Task.Factory.StartNew (() => { + var conn = GetConnection (); + using (conn.Lock ()) { + return conn.InsertAll (items); + } + }); + } [Obsolete("Will cause a deadlock if any call in action ends up in a different thread. Use RunInTransactionAsync(Action) instead.")] - public Task RunInTransactionAsync(Action action) - { - return Task.Factory.StartNew(() => - { - var conn = this.GetConnection(); - using (conn.Lock()) - { - conn.BeginTransaction(); - try - { - action(this); - conn.Commit(); - } - catch (Exception) - { - conn.Rollback(); - throw; - } - } - }); - } + public Task RunInTransactionAsync (Action action) + { + return Task.Factory.StartNew (() => { + var conn = this.GetConnection (); + using (conn.Lock ()) { + conn.BeginTransaction (); + try { + action (this); + conn.Commit (); + } + catch (Exception) { + conn.Rollback (); + throw; + } + } + }); + } public Task RunInTransactionAsync(Action action) { @@ -272,256 +249,238 @@ namespace SQLite }); } - public AsyncTableQuery Table() - where T : new() - { - // - // This isn't async as the underlying connection doesn't go out to the database - // until the query is performed. The Async methods are on the query iteself. - // - var conn = GetConnection(); - return new AsyncTableQuery(conn.Table()); - } - - public Task ExecuteScalarAsync(string sql, params object[] args) - { - return Task.Factory.StartNew(() => - { - var conn = GetConnection(); - using (conn.Lock()) - { - var command = conn.CreateCommand(sql, args); - return command.ExecuteScalar(); - } - }); - } - - public Task> QueryAsync(string sql, params object[] args) - where T : new() - { - return Task>.Factory.StartNew(() => - { - var conn = GetConnection(); - using (conn.Lock()) - { - return conn.Query(sql, args); - } - }); - } - } - - // - // TODO: Bind to AsyncConnection.GetConnection instead so that delayed - // execution can still work after a Pool.Reset. - // - public class AsyncTableQuery - where T : new() - { - TableQuery _innerQuery; - - public AsyncTableQuery(TableQuery innerQuery) - { - _innerQuery = innerQuery; - } - - public AsyncTableQuery Where(Expression> predExpr) - { - return new AsyncTableQuery(_innerQuery.Where(predExpr)); - } - - public AsyncTableQuery Skip(int n) - { - return new AsyncTableQuery(_innerQuery.Skip(n)); - } - - public AsyncTableQuery Take(int n) - { - return new AsyncTableQuery(_innerQuery.Take(n)); - } - - public AsyncTableQuery OrderBy(Expression> orderExpr) - { - return new AsyncTableQuery(_innerQuery.OrderBy(orderExpr)); - } - - public AsyncTableQuery OrderByDescending(Expression> orderExpr) - { - return new AsyncTableQuery(_innerQuery.OrderByDescending(orderExpr)); - } - - public Task> ToListAsync() - { - return Task.Factory.StartNew(() => - { - using (((SQLiteConnectionWithLock)_innerQuery.Connection).Lock()) - { - return _innerQuery.ToList(); - } - }); - } - - public Task CountAsync() - { - return Task.Factory.StartNew(() => - { - using (((SQLiteConnectionWithLock)_innerQuery.Connection).Lock()) - { - return _innerQuery.Count(); - } - }); - } - - public Task ElementAtAsync(int index) - { - return Task.Factory.StartNew(() => - { - using (((SQLiteConnectionWithLock)_innerQuery.Connection).Lock()) - { - return _innerQuery.ElementAt(index); - } - }); - } - - public Task FirstAsync() - { - return Task.Factory.StartNew(() => - { - using (((SQLiteConnectionWithLock)_innerQuery.Connection).Lock()) - { - return _innerQuery.First(); - } - }); - } - - public Task FirstOrDefaultAsync() - { - return Task.Factory.StartNew(() => - { - using (((SQLiteConnectionWithLock)_innerQuery.Connection).Lock()) - { - return _innerQuery.FirstOrDefault(); - } - }); - } - } - - public class CreateTablesResult - { - public Dictionary Results { get; private set; } - - internal CreateTablesResult() - { - this.Results = new Dictionary(); - } + public AsyncTableQuery Table () + where T : new () + { + // + // This isn't async as the underlying connection doesn't go out to the database + // until the query is performed. The Async methods are on the query iteself. + // + var conn = GetConnection (); + return new AsyncTableQuery (conn.Table ()); + } + + public Task ExecuteScalarAsync (string sql, params object[] args) + { + return Task.Factory.StartNew (() => { + var conn = GetConnection (); + using (conn.Lock ()) { + var command = conn.CreateCommand (sql, args); + return command.ExecuteScalar (); + } + }); + } + + public Task> QueryAsync (string sql, params object[] args) + where T : new () + { + return Task>.Factory.StartNew (() => { + var conn = GetConnection (); + using (conn.Lock ()) { + return conn.Query (sql, args); + } + }); + } + } + + // + // TODO: Bind to AsyncConnection.GetConnection instead so that delayed + // execution can still work after a Pool.Reset. + // + public class AsyncTableQuery + where T : new () + { + TableQuery _innerQuery; + + public AsyncTableQuery (TableQuery innerQuery) + { + _innerQuery = innerQuery; + } + + public AsyncTableQuery Where (Expression> predExpr) + { + return new AsyncTableQuery (_innerQuery.Where (predExpr)); + } + + public AsyncTableQuery Skip (int n) + { + return new AsyncTableQuery (_innerQuery.Skip (n)); + } + + public AsyncTableQuery Take (int n) + { + return new AsyncTableQuery (_innerQuery.Take (n)); + } + + public AsyncTableQuery OrderBy (Expression> orderExpr) + { + return new AsyncTableQuery (_innerQuery.OrderBy (orderExpr)); + } + + public AsyncTableQuery OrderByDescending (Expression> orderExpr) + { + return new AsyncTableQuery (_innerQuery.OrderByDescending (orderExpr)); + } + + public Task> ToListAsync () + { + return Task.Factory.StartNew (() => { + using (((SQLiteConnectionWithLock)_innerQuery.Connection).Lock ()) { + return _innerQuery.ToList (); + } + }); + } + + public Task CountAsync () + { + return Task.Factory.StartNew (() => { + using (((SQLiteConnectionWithLock)_innerQuery.Connection).Lock ()) { + return _innerQuery.Count (); + } + }); + } + + public Task ElementAtAsync (int index) + { + return Task.Factory.StartNew (() => { + using (((SQLiteConnectionWithLock)_innerQuery.Connection).Lock ()) { + return _innerQuery.ElementAt (index); + } + }); + } + + public Task FirstAsync () + { + return Task.Factory.StartNew(() => { + using (((SQLiteConnectionWithLock)_innerQuery.Connection).Lock ()) { + return _innerQuery.First (); + } + }); + } + + public Task FirstOrDefaultAsync () + { + return Task.Factory.StartNew(() => { + using (((SQLiteConnectionWithLock)_innerQuery.Connection).Lock ()) { + return _innerQuery.FirstOrDefault (); + } + }); + } } - class SQLiteConnectionPool - { - class Entry - { - public SQLiteConnectionString ConnectionString { get; private set; } - public SQLiteConnectionWithLock Connection { get; private set; } - - public Entry(SQLiteConnectionString connectionString) - { - ConnectionString = connectionString; - Connection = new SQLiteConnectionWithLock(connectionString); - } - - public void OnApplicationSuspended() - { - Connection.Dispose(); - Connection = null; - } - } - - readonly Dictionary _entries = new Dictionary(); - readonly object _entriesLock = new object(); - - static readonly SQLiteConnectionPool _shared = new SQLiteConnectionPool(); - - /// - /// Gets the singleton instance of the connection tool. - /// - public static SQLiteConnectionPool Shared - { - get - { - return _shared; - } - } - - public SQLiteConnectionWithLock GetConnection(SQLiteConnectionString connectionString) - { - lock (_entriesLock) - { - Entry entry; - string key = connectionString.ConnectionString; - - if (!_entries.TryGetValue(key, out entry)) - { - entry = new Entry(connectionString); - _entries[key] = entry; - } - - return entry.Connection; - } - } - - /// - /// Closes all connections managed by this pool. - /// - public void Reset() - { - lock (_entriesLock) - { - foreach (var entry in _entries.Values) - { - entry.OnApplicationSuspended(); - } - _entries.Clear(); - } - } - - /// - /// Call this method when the application is suspended. - /// - /// Behaviour here is to close any open connections. - public void ApplicationSuspended() - { - Reset(); - } - } - - class SQLiteConnectionWithLock : SQLiteConnection - { - readonly object _lockPoint = new object(); - - public SQLiteConnectionWithLock(SQLiteConnectionString connectionString) - : base(connectionString.DatabasePath, connectionString.StoreDateTimeAsTicks) - { - } - - public IDisposable Lock() - { - return new LockWrapper(_lockPoint); - } - - private class LockWrapper : IDisposable - { - object _lockPoint; - - public LockWrapper(object lockPoint) - { - _lockPoint = lockPoint; - Monitor.Enter(_lockPoint); - } - - public void Dispose() - { - Monitor.Exit(_lockPoint); - } - } - } + public class CreateTablesResult + { + public Dictionary Results { get; private set; } + + internal CreateTablesResult () + { + this.Results = new Dictionary (); + } + } + + class SQLiteConnectionPool + { + class Entry + { + public SQLiteConnectionString ConnectionString { get; private set; } + public SQLiteConnectionWithLock Connection { get; private set; } + + public Entry (SQLiteConnectionString connectionString) + { + ConnectionString = connectionString; + Connection = new SQLiteConnectionWithLock (connectionString); + } + + public void OnApplicationSuspended () + { + Connection.Dispose (); + Connection = null; + } + } + + readonly Dictionary _entries = new Dictionary (); + readonly object _entriesLock = new object (); + + static readonly SQLiteConnectionPool _shared = new SQLiteConnectionPool (); + + /// + /// Gets the singleton instance of the connection tool. + /// + public static SQLiteConnectionPool Shared + { + get + { + return _shared; + } + } + + public SQLiteConnectionWithLock GetConnection (SQLiteConnectionString connectionString) + { + lock (_entriesLock) { + Entry entry; + string key = connectionString.ConnectionString; + + if (!_entries.TryGetValue (key, out entry)) { + entry = new Entry (connectionString); + _entries[key] = entry; + } + + return entry.Connection; + } + } + + /// + /// Closes all connections managed by this pool. + /// + public void Reset () + { + lock (_entriesLock) { + foreach (var entry in _entries.Values) { + entry.OnApplicationSuspended (); + } + _entries.Clear (); + } + } + + /// + /// Call this method when the application is suspended. + /// + /// Behaviour here is to close any open connections. + public void ApplicationSuspended () + { + Reset (); + } + } + + class SQLiteConnectionWithLock : SQLiteConnection + { + readonly object _lockPoint = new object (); + + public SQLiteConnectionWithLock (SQLiteConnectionString connectionString) + : base (connectionString.DatabasePath, connectionString.StoreDateTimeAsTicks) + { + } + + public IDisposable Lock () + { + return new LockWrapper (_lockPoint); + } + + private class LockWrapper : IDisposable + { + object _lockPoint; + + public LockWrapper (object lockPoint) + { + _lockPoint = lockPoint; + Monitor.Enter (_lockPoint); + } + + public void Dispose () + { + Monitor.Exit (_lockPoint); + } + } + } }