Git Product home page Git Product logo

Comments (3)

martincostello avatar martincostello commented on August 17, 2024 1

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.

martincostello avatar martincostello commented on August 17, 2024

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:

https://github.com/justeat/httpclient-interception/blob/3585f27d60a16f432f73626150f02264d647b4cd/src/HttpClientInterception/HttpClientInterceptorOptions.cs#L68-L71

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.

kiquenet avatar kiquenet commented on August 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.