{"id":21947932,"url":"https://github.com/tinystuff/tinyhttpclientpool","last_synced_at":"2026-04-01T17:02:16.547Z","repository":{"id":69889787,"uuid":"114468442","full_name":"TinyStuff/TinyHttpClientPool","owner":"TinyStuff","description":"A HttpClient manager that allows cool stuff to happen","archived":false,"fork":false,"pushed_at":"2018-01-02T19:18:38.000Z","size":561,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-03-27T23:42:23.165Z","etag":null,"topics":["dotnet","dotnet-core","httpclient","pool","xamarin"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TinyStuff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-12-16T14:56:35.000Z","updated_at":"2024-03-20T22:46:35.000Z","dependencies_parsed_at":"2023-02-27T20:45:16.487Z","dependency_job_id":null,"html_url":"https://github.com/TinyStuff/TinyHttpClientPool","commit_stats":null,"previous_names":["johankson/tinyhttpclientpool"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TinyStuff/TinyHttpClientPool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TinyStuff%2FTinyHttpClientPool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TinyStuff%2FTinyHttpClientPool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TinyStuff%2FTinyHttpClientPool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TinyStuff%2FTinyHttpClientPool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TinyStuff","download_url":"https://codeload.github.com/TinyStuff/TinyHttpClientPool/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TinyStuff%2FTinyHttpClientPool/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31290538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dotnet","dotnet-core","httpclient","pool","xamarin"],"created_at":"2024-11-29T05:10:43.483Z","updated_at":"2026-04-01T17:02:16.533Z","avatar_url":"https://github.com/TinyStuff.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TinyHttpClientPool\nA HttpClient Pool that allows for reuse of http clients by assuring that you have the full and only access to an HttpClient during your use of it.\n\nIt is Tiny and only a few classes big.\n\n## Build status\n\n![Build status](https://io2gamelabs.visualstudio.com/_apis/public/build/definitions/be16d002-5786-41a1-bf3b-3e13d5e80aa0/13/badge)\n\n## Why use it?\n\n* Exclusive access to an HttpClient while calling\n* Allows for custom headers per request while reusing HttpClients\n* Pools are cool\n\n## Why is it created\n\nIt's created with Xamarin in mind and that's where we use it.\n\n## Usage\n\n### Getting an instance of the pool manager\n\nThere are a few ways to get a hold of an instance.\n\n```csharp\n// A) Just create a new instance\nvar pool = new TinyHttpClientPool();\n\n// B) Use the static helpers\nTinyHttpClientPool.Initialize();\nvar client = TinyHttpClientPool.FetchClient();\n\n// C) Register the interface into your favorite IoC container\nvar pool = Resolver.Resolve\u003cITinyHttpClientPool\u003e();\n```\n\nThe usage from this point on is pretty straight forward\n\n```csharp\n// Create an instance in any way above\nvar pool = new TinyHttpClientPool();\n\n// Always use a using around the client!\nusing (HttpClient client = pool.Fetch())\n{\n    // As long as you are in the using, the instance\n    // is yours and yours alone\n    var result = await client.GetStringAsync(url);\n}\n\n// At this point it is returned to the pool\n```\n\n## Initialization\n\u003e Note: We are currently working on a better way to initialize the pool. But for the time being, you can hook up to the ```ClientInitialization``` action and configure each new ```HttpClient``` with default values.\n\u003e\n\u003e What we are thinking of is a configuration object passed into the constructor of the Initialize call and/or the constructor of the TinyHttpClientPool class.\n\nFor example, setting a common base url on each new ```HttpClient```is done like this:\n```csharp\n TinyHttpClientPool.Current.ClientInitializationOnCreation = (obj) =\u003e obj.BaseAddress = new Uri(BackendUrl);\n```\n\nYou can also run common code on each fetch.\n```csharp\nTinyHttpClientPool.Current.ClientInitializationOnFetch = (obj) =\u003e ChangeHeaders(obj);\n```\n\n## Monitoring\n\nYou can monitor the pool size and number of available ```HttpClients``` and hook up to the ```PoolChanged``` event to be notified if something changes.\n\n```csharp\nTinyHttpClientPool.Current.PoolChanged += (sender, e) =\u003e\n{\n    PoolSize = TinyHttpClientPool.Current.TotalPoolSize;\n    Available = TinyHttpClientPool.Current.AvailableCount;\n}\n```\n\n## Cleanup\n\nIf you want to flush the pool, simply call ```Flush()```\n\n```csharp\npool.Flush();\n```\n\nThis will dispose any ```HttpClient``` that is in the ```Available``` state but not touch those who are in the ```InUse``` state.\n\n## Important\n\nFor this to work, you must dispose the client when you are done with it. There is no other way to return it to the pool. Well, there is one way...\n\nThe returned client isn't really an ```HttpClient```, but rather a ```TinyHttpClient``` that inherits from ```HttpClient```.\n\nSo you could manually set the state to ```State.Available``` but that is at your own risk.\n\n```csharp\nvar client = pool.Fetch() as TinyHttpClient;\n\n// do stuff with client here\n\n// Mark it as ready for the pool to reuse\nclient.State = State.Available; \n```\n\n\n## Roadmap\n\nThere isn't really any roadmap to this since it's pretty much done the way it's supposed to work. But if you're missing a feature, create an issue or better yet, create a PR. :)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinystuff%2Ftinyhttpclientpool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftinystuff%2Ftinyhttpclientpool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinystuff%2Ftinyhttpclientpool/lists"}