Replies: 3 comments 2 replies
|
You could do a HEAD request. That way you avoid the full download but get whatever info you need. |
1 reply
|
Yes, I thought that too. But still, a request for every request to the image feels wrong, maybe I can cache it... HMAC sounds like a good idea, need to read up on that! |
0 replies
|
I added a request (with caching according to response headers) in the provider > skttl/ImageSharpCommunity.Providers.Remote#4 Seeking advice, if I should worry about anything for this? |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I've created a provider for fetching images over http (https://github.com/skttl/ImageSharpCommunity.Providers.Remote/).
From time to time I run in to a problem where bots or users are requesting images that simply doesn't exist. Eg.
/remote/nonexisting.com/404.jpg.This returns a 500 error, since the stream returned in https://github.com/skttl/ImageSharpCommunity.Providers.Remote/blob/main/src/ImageSharpCommunity.Providers.Remote/RemoteImageResolver.cs#L47 doesn't contain an image.
I would love if I could return a 404 from here, but the only possible solution I can think if, is by adding a request in the provider (https://github.com/skttl/ImageSharpCommunity.Providers.Remote/blob/main/src/ImageSharpCommunity.Providers.Remote/RemoteImageProvider.cs#L43) to check if the url returns anything.
But I think that would make it do that request every time the image is requested from
/remote/nonexisting.com/404.jpg, and also when requesting images that actually exists. Doing the request for images we "don't know" yet is not a problem, we do it anyway in the resolver. But having that request each and every time a "known" image, that might already be in the ImageSharp.Web cache feels wrong.Am I wrong, or is there a better way of doing this?
All reactions