Comments (3)
That's expected behaviour - you've configured a response for GET https://{Host}/api/v1/getEnvironment
and nothing for GET https://sql-pre:60011/obtenerEntornoDirectorioActivo
.
You need to set up something to respond to the request for that HTTP GET.
from httpclient-interception.
Requests successfully intercepted by the library will never interact with the HTTPS/TLS stack, so isn't a direct concern of this library.
If you never want a real HTTP request to be made, then set ThrowOnMissingRegistration
to true
:
You would then just need to add the missing registrations to intercept the relevant requests causing the exceptions.
If you do want real requests to be made if an interception isn't registered, then the standard way to do with with HttpClient
is to provide a custom handler and disable certification validation:
var handler = new HttpClientHandler();
handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
var httpClient = new HttpClient(handler);
In the above scenario, then you will need to compose the handler from CreateHttpMessageHandler()
with that handler so that the interception is in the HTTP pipeline.
Using IHttpClientFactory
(as described here) makes this easier. There is an example of this approach in the sample application.
from httpclient-interception.
Fails for me using this code:
AuthenticationException: The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch
var builder = new HttpRequestInterceptionBuilder()
.ForHost(Host)
.ForPath("/api/v1/getEnvironment")
.ForHttps()
.ForMethod(HttpMethod.Get)
.WithJsonContent(new { });
var options = new HttpClientInterceptorOptions().Register(builder);
var client = options.CreateHttpClient(new Uri(Uri));
I try this:
var builder = new HttpRequestInterceptionBuilder()
.ForHost(Host)
.ForPath("/api/v1/getEnvironment")
.ForHttps()
.ForMethod(HttpMethod.Get)
.WithJsonContent(new { });
var options = new HttpClientInterceptorOptions().Register(builder);
options.ThrowOnMissingRegistration = true;
var client = options.CreateHttpClient(new Uri(Uri));
and I get
JustEat.HttpClientInterception.HttpRequestNotInterceptedException: No HTTP response is configured for GET https://sql-pre:60011/obtenerEntornoDirectorioActivo.
from httpclient-interception.
Related Issues (20)
- Allow access to CancellationToken HOT 2
- Question: How to simulate a timeout/no response from downstream service HOT 2
- request: more examples for response changing based on how many times called so far HOT 4
- Improve custom matching HOT 3
- NullReferenceException when Deregister builder with a custom matcher HOT 2
- Verify calls to the registered end points have been called [discussion] HOT 8
- Same request but with different responses HOT 4
- Add [StringSyntax] attributes HOT 2
- Remove Newtonsoft.Json
- Async RegisterBundle() overloads
- WithResponseHeaders and WithContentHeaders overloads HOT 7
- Response sequence HOT 1
- Add exception list for urls to ignore when ThrowOnMissingRegistration is true
- Question: Should HttpClient created from HttpClientInterceptorOptions auto-follow redirects? HOT 1
- Ignore order of query params HOT 4
- after upgrade, build error HOT 4
- Test Failures Due to Authorization Issues After Upgrading to .NET 8 and HttpClient-Interception HOT 1
- Revise documentation covering usage together with IHttpClientFactory HOT 5
- Including existing registrations in HttpRequestNotInterceptedException HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from httpclient-interception.