Coder Social home page Coder Social logo

Comments (2)

philliphoff avatar philliphoff commented on June 2, 2024

@TWEESTY If I understand correctly, the issue is that CreateInvokeHttpClient() stores the application ID in the BaseAddress property of the returned HttpClient, and that property is treated case-insensitively when it's pulled back out by the InvocationHandler attached to the HttpClient (because hosts are generally case-insensitive for the purpose of HTTP requests)?

But, looking at the code, the BaseAddress appears used solely for the purpose of storing the application ID. I wonder why we would do that vs. just storing the application ID in a property of the InvocationHandler itself, as we do DaprEndpoint, other than it just seemed convenient at the time. That would seemingly allow application IDs with uppercase letters (which should generally be valid to Dapr).

(I'm also curious as to why the application ID is optional in CreateInvokeHttpClient(), as the code seems to assume it's set.)

from dotnet-sdk.

TWEESTY avatar TWEESTY commented on June 2, 2024

@philliphoff : Yes, you understand correctly.
You're right, we should add a property AppId to the InvocationHandler , but we need also to set the BaseAddress with the "AppId" (if set), else an exception will be thrown if you do this like that (ie with no hostname).
httpClient.PostAsJsonAsync($"orders", content);

And no, we can called CreateInvokeHttpClient without the appId parameter, there is no issue to do that. But in order to send a request, we need to pass all the URI (i.e. with the AppId) like that :
httpClient.PostAsJsonAsync($"http://order-processor/orders", content);

If the developer called CreateInvokeHttpClient with a non null string for appId , then it is simple, inside the InvocationHandler this Path = $"/v1.0/invoke/{uri.Host}/method" + uri.AbsolutePath, should be replaced by Path = $"/v1.0/invoke/{AppId}/method" + uri.AbsolutePath,

If the developer called CreateInvokeHttpClient with no appId , then inside the InvocationHandler this Path = $"/v1.0/invoke/{uri.Host}/method" + uri.AbsolutePath, should be replaced by Path = $"/v1.0/invoke/{uri.OriginalString.GetHost()}/method" + uri.AbsolutePath,

If we don't set the AppId when called the CreateInvokeHttpClient, we can use the same HttpClient for several services. It's nice.

I guess there is still one issue, how to deal if the developer changes the httpClient.BaseAddress and the developper set appId (when when called the CreateInvokeHttpClient) => Maybe, the InvocationHandler should not replace the path by AppId if AppId is not equal to the URI Host (comparison no case sensitive).

Do not hesitate if you have some questions.

So, it is clear in my head, I will do a MR.

from dotnet-sdk.

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.