{"id":15410084,"url":"https://github.com/aarnott/httpclientecho","last_synced_at":"2026-01-19T06:02:38.443Z","repository":{"id":66192805,"uuid":"134119638","full_name":"AArnott/HttpClientEcho","owner":"AArnott","description":"Enables automated tests with HTTP calls to avoid incurring the cost and instability of network traffic by recording a \"live\" test run and replaying it for subsequent test runs.","archived":false,"fork":false,"pushed_at":"2018-05-26T18:48:29.000Z","size":236,"stargazers_count":3,"open_issues_count":4,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-27T14:11:49.662Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"ms-pl","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AArnott.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}},"created_at":"2018-05-20T04:28:13.000Z","updated_at":"2023-01-17T08:26:45.000Z","dependencies_parsed_at":"2023-02-24T08:45:55.900Z","dependency_job_id":null,"html_url":"https://github.com/AArnott/HttpClientEcho","commit_stats":{"total_commits":29,"total_committers":1,"mean_commits":29.0,"dds":0.0,"last_synced_commit":"4c89ce1e32fe7a9d2a53db3273c1953d3dc23799"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/AArnott/HttpClientEcho","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AArnott%2FHttpClientEcho","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AArnott%2FHttpClientEcho/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AArnott%2FHttpClientEcho/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AArnott%2FHttpClientEcho/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AArnott","download_url":"https://codeload.github.com/AArnott/HttpClientEcho/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AArnott%2FHttpClientEcho/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28562239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T03:31:16.861Z","status":"ssl_error","status_checked_at":"2026-01-19T03:31:15.069Z","response_time":67,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":[],"created_at":"2024-10-01T16:42:52.168Z","updated_at":"2026-01-19T06:02:38.427Z","avatar_url":"https://github.com/AArnott.png","language":"C#","readme":"# HttpClientEcho\n\n[![NuGet](https://img.shields.io/nuget/v/HttpClientEcho.svg)](https://nuget.org/packages/HttpClientEcho)\n[![Build status](https://ci.appveyor.com/api/projects/status/g2b03pfq01mluh6w/branch/master?svg=true)](https://ci.appveyor.com/project/AArnott/httpclientecho/branch/master)\n[![Build Status](https://travis-ci.org/AArnott/HttpClientEcho.svg?branch=master)](https://travis-ci.org/AArnott/HttpClientEcho)\n[![codecov](https://codecov.io/gh/AArnott/HttpClientEcho/branch/master/graph/badge.svg)](https://codecov.io/gh/AArnott/HttpClientEcho)\n\n\nEnables automated testing to test all local code without actually incurring\nthe cost and instability of network traffic, by recording a \"live\" test run\nand replaying it for subsequent test runs.\n\n## Usage\n\nConsider the simplest use case of an HTTP call in a test:\n\n```csharp\n[Fact]\npublic async Task Simple()\n{\n    var httpClient = new HttpClient();\n    var response = await httpClient.GetAsync(\"https://www.bing.com/\");\n    response.EnsureSuccessStatusCode();\n}\n```\n\nThe above test fails if the network fails or if the server throttles your tests requests.\nBy leveraging `HttpClientEcho` we can isolate this test from the network while still\nemulating the server's full response.\n\nFirst, install the [`HttpClientEcho` NuGet package][NuGet].\nThene simply pass in a `new EchoMessageHandler()` to the `HttpClient` constructor:\n\n```csharp\n[Fact]\npublic async Task Simple()\n{\n    var httpClient = new HttpClient(new EchoMessageHandler());\n    var response = await httpClient.GetAsync(\"https://www.bing.com/\");\n    response.EnsureSuccessStatusCode();\n}\n```\n\nThe first time you run the test, it will contact the server and cache the result\nwith your test project (and tracked in source control where applicable).\nSubsequent runs of your test will reuse the cached response and avoid the network call.\n\n## How it works\n\nThe first time you run your tests, your test project transitions from this cache-less version:\n\n![Project with no cache](doc/images/SolutionExplorer_no_cache.png)\n\nAfter your test run, a cache file is added to your project:\n\n![Project with HTTP cache](doc/images/SolutionExplorer_with_cache.png)\n\nThe cache file itself is an easy-to-read representation of the network traffic that took place.\nIt is your HTTP traffic serialized in a near-HTTP protocol like fashion. For example,\nwith one cached request+response, the file would look something like this:\n\n```\nGET https://www.bing.com/\n\n200 OK\nContent-Length: 9\nContent-Type: text/html; charset=utf-8\n\nsome data\n```\n\n[NuGet]: https://nuget.org/packages/HttpClientEcho\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faarnott%2Fhttpclientecho","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faarnott%2Fhttpclientecho","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faarnott%2Fhttpclientecho/lists"}