Introduction
editThe Meziantou.Framework.Http.* packages add features to HttpClient that it does not have on its own. Most of them are a DelegatingHandler: you put it in the pipeline of a client, and every request that goes through the client gets the feature. The others parse HTTP formats.
What you can do with them
- Cache responses on the client, following the HTTP caching rules: freshness, validation with
ETagandLast-Modified,Vary,No-Vary-Search,immutableandstale-if-error. Keep the cache in memory, in a file, in SQLite or in Redis. See Caching. - Enforce HSTS: send the requests to the hosts that require HTTPS over HTTPS, even when the URL says
http://, with the HSTS preload list built in. See HSTS. - Block server-side request forgery when your application fetches URLs it does not control: reject the schemes, the IP addresses and the networks it must not reach, checked on every connection. See Server-side request forgery.
- Record and replay the traffic of an
HttpClientin tests, to a JSON or a HAR file, with the secrets removed. See Recording. - Parse
Linkheaders (RFC 8288), for instance to follow pagination links. See Link headers. - Verify credentials against an Apache htpasswd file. See Htpasswd files.
Packages
| Package | Main types | Pages |
|---|---|---|
Meziantou.Framework.Http | LinkHeaderValue | Link headers |
Meziantou.Framework.Http.Caching | HttpCachingDelegateHandler, IHttpCacheStore | Caching |
Meziantou.Framework.Http.Caching.InMemory | InMemoryHttpCacheStore | Caching |
Meziantou.Framework.Http.Caching.Sqlite | SqliteHttpCacheStore | Caching |
Meziantou.Framework.Http.Caching.Redis | RedisHttpCacheStore | Caching |
Meziantou.Framework.Http.Hsts | HstsClientHandler, HstsDomainPolicyCollection | HSTS |
Meziantou.Framework.Http.Htpasswd | HtpasswdFile | Htpasswd files |
Meziantou.Framework.Http.Recording | HttpRecordingHandler | Recording |
Meziantou.Framework.Http.ServerSideRequestForgery | ServerSideRequestForgeryClientHandler | Server-side request forgery |
Each package is independent: install only the ones you need. The HAR files that the recording package reads and writes are described by the HttpArchive package.
Next steps
- Getting started: install a package and add a handler to an
HttpClient.