diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index cc88f801..d323d270 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -88,14 +88,14 @@ jobs: shell: bash run: | sudo npm install -g azurite - sudo azurite --loose & + sudo azurite --loose --skipApiVersionCheck & - name: Azurite Setup Windows if: matrix.options.os == 'windows-latest' shell: bash run: | npm install -g azurite - azurite --loose & + azurite --loose --skipApiVersionCheck & - name: S3rver Setup if: matrix.options.os != 'windows-latest' diff --git a/README.md b/README.md index 7ebdd348..5b80433b 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ On Windows to install and run the server as a background process run the followi ```bash npm install -g azurite -start /B azurite --loose +start /B azurite --loose --skipApiVersionCheck npm install -g s3rver start /B s3rver -d . @@ -100,7 +100,7 @@ On Linux ```bash sudo npm install -g azurite -sudo azurite --loose & +sudo azurite --loose --skipApiVersionCheck & sudo npm install -g s3rver sudo s3rver -d . & diff --git a/src/ImageSharp.Web.Providers.AWS/Caching/AWSS3StorageCache.cs b/src/ImageSharp.Web.Providers.AWS/Caching/AWSS3StorageCache.cs index 676dbeca..a957f067 100644 --- a/src/ImageSharp.Web.Providers.AWS/Caching/AWSS3StorageCache.cs +++ b/src/ImageSharp.Web.Providers.AWS/Caching/AWSS3StorageCache.cs @@ -60,7 +60,8 @@ public Task SetAsync(string key, Stream stream, ImageCacheMetadata metadata) Key = this.GetKeyWithFolder(key), ContentType = metadata.ContentType, InputStream = stream, - AutoCloseStream = false + AutoCloseStream = false, + UseChunkEncoding = false }; foreach (KeyValuePair d in metadata.ToDictionary()) @@ -141,7 +142,7 @@ private static readonly TaskFactory TaskFactory /// /// Executes an async method synchronously. /// - /// The task to excecute. + /// The task to execute. public static void RunSync(Func task) { CultureInfo cultureUi = CultureInfo.CurrentUICulture; @@ -159,7 +160,7 @@ public static void RunSync(Func task) /// a return type synchronously. /// /// The type of result to return. - /// The task to excecute. + /// The task to execute. /// The . public static TResult RunSync(Func> task) { diff --git a/src/ImageSharp.Web.Providers.AWS/ImageSharp.Web.Providers.AWS.csproj b/src/ImageSharp.Web.Providers.AWS/ImageSharp.Web.Providers.AWS.csproj index a899bc38..41a35fa7 100644 --- a/src/ImageSharp.Web.Providers.AWS/ImageSharp.Web.Providers.AWS.csproj +++ b/src/ImageSharp.Web.Providers.AWS/ImageSharp.Web.Providers.AWS.csproj @@ -43,7 +43,7 @@ - + diff --git a/src/ImageSharp.Web.Providers.AWS/Resolvers/AWSS3StorageCacheResolver.cs b/src/ImageSharp.Web.Providers.AWS/Resolvers/AWSS3StorageCacheResolver.cs index 6e83f892..2add992f 100644 --- a/src/ImageSharp.Web.Providers.AWS/Resolvers/AWSS3StorageCacheResolver.cs +++ b/src/ImageSharp.Web.Providers.AWS/Resolvers/AWSS3StorageCacheResolver.cs @@ -38,7 +38,7 @@ public Task GetMetaDataAsync() foreach (string key in this.metadata.Keys) { // Trim automatically added x-amz-meta- - dict.Add(key.Substring(11).ToUpperInvariant(), this.metadata[key]); + dict.Add(key[11..].ToUpperInvariant(), this.metadata[key]); } return Task.FromResult(ImageCacheMetadata.FromDictionary(dict)); diff --git a/src/ImageSharp.Web.Providers.AWS/Resolvers/AWSS3StorageImageResolver.cs b/src/ImageSharp.Web.Providers.AWS/Resolvers/AWSS3StorageImageResolver.cs index dd7c2b4e..42e042fd 100644 --- a/src/ImageSharp.Web.Providers.AWS/Resolvers/AWSS3StorageImageResolver.cs +++ b/src/ImageSharp.Web.Providers.AWS/Resolvers/AWSS3StorageImageResolver.cs @@ -49,9 +49,10 @@ public async Task GetMetaDataAsync() } } - return new ImageMetadata(metadata.LastModified, maxAge, metadata.ContentLength); + return new ImageMetadata(metadata.LastModified ?? DateTime.UtcNow, maxAge, metadata.ContentLength); } /// - public Task OpenReadAsync() => this.amazonS3.GetObjectStreamAsync(this.bucketName, this.imagePath, null); + public Task OpenReadAsync() + => this.amazonS3.GetObjectStreamAsync(this.bucketName, this.imagePath, null); } diff --git a/src/ImageSharp.Web.Providers.Azure/ImageSharp.Web.Providers.Azure.csproj b/src/ImageSharp.Web.Providers.Azure/ImageSharp.Web.Providers.Azure.csproj index 90be6e45..da7e9305 100644 --- a/src/ImageSharp.Web.Providers.Azure/ImageSharp.Web.Providers.Azure.csproj +++ b/src/ImageSharp.Web.Providers.Azure/ImageSharp.Web.Providers.Azure.csproj @@ -1,4 +1,4 @@ - + SixLabors.ImageSharp.Web.Providers.Azure @@ -43,7 +43,7 @@ - + diff --git a/src/ImageSharp.Web/Middleware/ImageContext.cs b/src/ImageSharp.Web/Middleware/ImageContext.cs index 84e63ec9..15747cf8 100644 --- a/src/ImageSharp.Web/Middleware/ImageContext.cs +++ b/src/ImageSharp.Web/Middleware/ImageContext.cs @@ -61,7 +61,7 @@ public ImageContext(HttpContext context, ImageSharpMiddlewareOptions options) internal enum PreconditionState { /// - /// Unspeciified + /// Unspecified /// Unspecified, @@ -88,7 +88,7 @@ internal enum PreconditionState /// The combined components of the image request URL in a fully un-escaped form (except /// for the QueryString) suitable only for display. /// - public string GetDisplayUrl() => this.request.GetDisplayUrl(); + public readonly string GetDisplayUrl() => this.request.GetDisplayUrl(); /// /// Analyzes the headers for the current request. @@ -110,7 +110,7 @@ public void ComprehendRequestHeaders(DateTimeOffset lastModified, long length) /// Gets the preconditioned state of the request. /// /// The . - public PreconditionState GetPreconditionState() + public readonly PreconditionState GetPreconditionState() => GetMaxPreconditionState( this.ifMatchState, this.ifNoneMatchState, @@ -121,7 +121,7 @@ public PreconditionState GetPreconditionState() /// Gets a value indicating whether this request is a head request. /// /// THe . - public bool IsHeadRequest() + public readonly bool IsHeadRequest() => string.Equals("HEAD", this.request.Method, StringComparison.OrdinalIgnoreCase); /// @@ -130,7 +130,7 @@ public bool IsHeadRequest() /// The status code. /// The image metadata. /// The . - public Task SendStatusAsync(int statusCode, in ImageCacheMetadata metaData) + public readonly Task SendStatusAsync(int statusCode, in ImageCacheMetadata metaData) => this.ApplyResponseHeadersAsync( statusCode, metaData.ContentType, @@ -142,7 +142,7 @@ public Task SendStatusAsync(int statusCode, in ImageCacheMetadata metaData) /// The output stream. /// The image metadata. /// The . - public async Task SendAsync(Stream stream, ImageCacheMetadata metaData) + public readonly async Task SendAsync(Stream stream, ImageCacheMetadata metaData) { await this.ApplyResponseHeadersAsync( ResponseConstants.Status200Ok, @@ -176,7 +176,7 @@ private static PreconditionState GetMaxPreconditionState(params PreconditionStat return max; } - private async Task ApplyResponseHeadersAsync( + private readonly async Task ApplyResponseHeadersAsync( int statusCode, string contentType, TimeSpan maxAge) diff --git a/src/ImageSharp.Web/Middleware/ResponseConstants.cs b/src/ImageSharp.Web/Middleware/ResponseConstants.cs index 7d196f83..33aee4f0 100644 --- a/src/ImageSharp.Web/Middleware/ResponseConstants.cs +++ b/src/ImageSharp.Web/Middleware/ResponseConstants.cs @@ -4,7 +4,7 @@ namespace SixLabors.ImageSharp.Web.Middleware; /// -/// Contains constants related to HTTP respose codes. +/// Contains constants related to HTTP response codes. /// internal static class ResponseConstants { diff --git a/src/ImageSharp.Web/Providers/PhysicalFileSystemProvider.cs b/src/ImageSharp.Web/Providers/PhysicalFileSystemProvider.cs index 7634e20f..25bbc5b6 100644 --- a/src/ImageSharp.Web/Providers/PhysicalFileSystemProvider.cs +++ b/src/ImageSharp.Web/Providers/PhysicalFileSystemProvider.cs @@ -33,6 +33,9 @@ public PhysicalFileSystemProvider( /// The web root path. /// The content root path. /// representing the fully qualified provider root path. + /// + /// Thrown when the provider root path cannot be determined. + /// internal static string GetProviderRoot(PhysicalFileSystemProviderOptions options, string webRootPath, string contentRootPath) { string providerRootPath = options.ProviderRootPath ?? webRootPath; diff --git a/tests/ImageSharp.Web.Tests/TestUtilities/AWSS3StorageImageProviderFactory.cs b/tests/ImageSharp.Web.Tests/TestUtilities/AWSS3StorageImageProviderFactory.cs index bbfb8a5d..38e74d43 100644 --- a/tests/ImageSharp.Web.Tests/TestUtilities/AWSS3StorageImageProviderFactory.cs +++ b/tests/ImageSharp.Web.Tests/TestUtilities/AWSS3StorageImageProviderFactory.cs @@ -81,7 +81,7 @@ private static async Task InitializeAWSStorageAsync(IServiceProvider services, A catch { IFileInfo file = environment.WebRootFileProvider.GetFileInfo(TestConstants.ImagePath); - using Stream stream = file.CreateReadStream(); + await using Stream stream = file.CreateReadStream(); // Set the max-age property so we get coverage for testing in our AWS provider. CacheControlHeaderValue cacheControl = new() @@ -100,7 +100,9 @@ private static async Task InitializeAWSStorageAsync(IServiceProvider services, A CacheControl = cacheControl.ToString() }, ContentType = " image/png", - InputStream = stream + InputStream = stream, + AutoCloseStream = false, + UseChunkEncoding = false, }; await amazonS3Client.PutObjectAsync(putRequest); diff --git a/tests/ImageSharp.Web.Tests/TestUtilities/ServerTestBase.cs b/tests/ImageSharp.Web.Tests/TestUtilities/ServerTestBase.cs index e4e03512..89bb989b 100644 --- a/tests/ImageSharp.Web.Tests/TestUtilities/ServerTestBase.cs +++ b/tests/ImageSharp.Web.Tests/TestUtilities/ServerTestBase.cs @@ -21,11 +21,13 @@ protected ServerTestBase(TFixture fixture, ITestOutputHelper outputHelper, strin this.OutputHelper = outputHelper; this.ImageSource = imageSource; - this.OutputHelper.WriteLine("EnvironmentalVariables"); - foreach (DictionaryEntry item in Environment.GetEnvironmentVariables()) - { - this.OutputHelper.WriteLine($"Key = {item.Key}, Value = {item.Value}"); - } + this.OutputHelper.WriteLine(typeof(TFixture).Name); + + //this.OutputHelper.WriteLine("EnvironmentalVariables"); + //foreach (DictionaryEntry item in Environment.GetEnvironmentVariables()) + //{ + // this.OutputHelper.WriteLine($"Key = {item.Key}, Value = {item.Value}"); + //} } public TFixture Fixture { get; }