Skip to content

Commit 8bfe51f

Browse files
No need to create a new context.
1 parent 5fca9ce commit 8bfe51f

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/ImageSharp.Web/Middleware/ImageContext.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,12 @@ internal enum PreconditionState
8686
}
8787

8888
/// <summary>
89-
/// Returns the current HTTP request display url.
89+
/// Returns the current HTTP image request display url.
9090
/// </summary>
91-
/// <returns>The. </returns>
91+
/// <returns>
92+
/// The combined components of the image request URL in a fully un-escaped form (except
93+
/// for the QueryString) suitable only for display.
94+
/// </returns>
9295
public string GetDisplayUrl() => this.request.GetDisplayUrl();
9396

9497
/// <summary>

src/ImageSharp.Web/Middleware/ImageSharpMiddleware.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Linq;
1010
using System.Threading.Tasks;
1111
using Microsoft.AspNetCore.Http;
12+
using Microsoft.AspNetCore.Http.Extensions;
1213
using Microsoft.Extensions.Logging;
1314
using Microsoft.Extensions.Options;
1415
using Microsoft.IO;
@@ -238,8 +239,7 @@ await this.options.OnParseCommandsAsync.Invoke(
238239
{
239240
// Log the error but let the pipeline handle the 404
240241
// by calling the next delegate/middleware in the pipeline.
241-
var imageContext = new ImageContext(httpContext, this.options);
242-
this.logger.LogImageResolveFailed(imageContext.GetDisplayUrl());
242+
this.logger.LogImageResolveFailed(httpContext.Request.GetDisplayUrl());
243243
await this.next(httpContext);
244244
return;
245245
}

0 commit comments

Comments
 (0)