-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should HttpTileSource implement IDisposable? #125
Comments
Yes, that is correct. One way to resolve this is to add the IDisposable, but this will make everything else that is using it IDisposable. Perhaps there is another way where we keep the HttpClient more on the outside. This is also needed for setting properties like the referrer. Also it is advised these days to use a factory for HttpClient to allow reuse. So perhaps there should be some central factory that could be configured... not sure how to resolve this. Perhaps leave it like this for now. It is not possible to set the referrer on the HttpClient within the the HttpTileSource but it is possible to pass in your own tile fetch method in which you can use your own HttpClient with the settings your choose. Here is an example for google maps setting the referrer: |
I agree that having IDisposable on HttpTileSource is annoying, especially when providing a tileFetcher where HttpClient is not even used. |
I was thinking about using a HttpClientFactory to avoid having to make HttpTileSource disposable. This page mentions this about the HttpClient:
So, indeed it should not be disposed but we should use a factory instead. Microsoft has:
I would not like to add this as a dependency. If it is not in the standard dotnet we could add something like this ourselves. |
I was searching if I could set the 'Referrer' Property of the HttpClient used by HttpTileSource, when I noticed that HttpClient is IDisposable (through HttpMessageInvoker) and HttpTileSource does not implement IDisposable. Doesn't this violate this rule?
The text was updated successfully, but these errors were encountered: