Add WinHTTP Transport support to the SDK for windows clients as another HTTP Transport.#897
Conversation
…er HTTP Transport.
vhvb1989
left a comment
There was a problem hiding this comment.
- Changelog
- Readme docs about how to build and use
Really recommending to split the code from send() into multiple components. It is currently creating the handles, sending request , reading/parsing response and creating rawResponse.
- The handles are copied to the bodyStream. Add a destructor for the bodyStream to clean the handles. Only the Send() method is caring about
CleanupHandlesAndThrow, but if Read() fails or if the bodyStream is disposed, are we leaking?
Create an abstraction for writing/reading from the wire with an interface. Then create a derive class to implement the interface. This will let you create a mocked derived object to emulate the server's responses.
That is already happening. We are not leaking :) See: |
This reverts commit d44253f.
|
This pull request is protected by Check Enforcer. What is Check Enforcer?Check Enforcer helps ensure all pull requests are covered by at least one check-run (typically an Azure Pipeline). When all check-runs associated with this pull request pass then Check Enforcer itself will pass. Why am I getting this message?You are getting this message because Check Enforcer did not detect any check-runs being associated with this pull request within five minutes. This may indicate that your pull request is not covered by any pipelines and so Check Enforcer is correctly blocking the pull request being merged. What should I do now?If the check-enforcer check-run is not passing and all other check-runs associated with this PR are passing (excluding license-cla) then you could try telling Check Enforcer to evaluate your pull request again. You can do this by adding a comment to this pull request as follows: What if I am onboarding a new service?Often, new services do not have validation pipelines associated with them, in order to bootstrap pipelines for a new service, you can issue the following command as a pull request comment: |
|
/azp run cpp - storage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Azure Pipelines successfully started running 1 pipeline(s). |
vhvb1989
left a comment
There was a problem hiding this comment.
Adding a few comments.
Feel free to create issues to address those things in the future if you are ready to merge.
| private: | ||
| WinHttpTransportOptions m_options; | ||
|
|
||
| void GetSessionHandle(std::unique_ptr<Details::HandleManager>& handleManager); |
There was a problem hiding this comment.
I don't know if it would just better to use a pointer here like Details::HandleManager const* const or Details::HandleManager * const.
The main purpose of using the unique_ptr is to handle the ownership and ensure only only owner. My recommendation is to change this signatures to a raw pointer. We can still keep a unique_ptr wherever it's need, We can get the raw pointer from the unique_ptr by calling .get().
@antkmsft , I would like to hear from you here since you know better understanding of this
| GetSessionHandle(handleManager); | ||
| GetConnectionHandle(handleManager); | ||
| GetRequestHandle(handleManager); | ||
|
|
||
| SendRequest(handleManager); | ||
|
|
||
| ReceiveResponse(handleManager); | ||
|
|
||
| return GetRawResponse(handleManager, request.GetMethod()); |
There was a problem hiding this comment.
All these methods dont's need to get a unique_ptr.
Instead, they can just take a referece or a raw pointer to HandleManager.
The benefit, if it just a reference, is that you never worry about null argument exception.
See, I made this example on how to pass a reference from a unique_ptr, I recommend following this approach here
https://godbolt.org/z/71G7nd
There was a problem hiding this comment.
Given this is an implementation detail and seems somewhat subjective, I am inclined to leave it as is for now.
One thing I need is the destructor of handleManager to be called whenever we throw. Would passing them as raw pointers or a reference still let that happen?
update AddHeader docs, and remove TODOs in source.
… into WinHttpTransport
…ious signature with pointers.
AddHeader method that takes iterators.
|
/azp run cpp - storage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run cpp - storage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
vhvb1989
left a comment
There was a problem hiding this comment.
Adding some responses
Also mentioning an issue with the unique_ptr that needs to be fixed before merging.
The WinHttpBodyStream is currently stealing the handleManager ownership instead of expecting to become the owner
| // Specify an HTTP server. | ||
| // Uses port 80 for HTTP and port 443 for HTTPS. | ||
| // This function always operates synchronously. | ||
| handleManager->m_connectionHandle = WinHttpConnect( |
There was a problem hiding this comment.
It's not managing anything. It is acting just as a container or bag. But any name you decide is up to up as the author.
|
/azp run cpp - storage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Hello @ahsonkhan! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
|
Thanks for the great and detailed feedback @vhvb1989. Appreciate it! If anyone else has any other pressing feedback or wants me to change something, please review it and let me know and I will address it separately. In the interest of time, given the duration and size of this PR and conversation, I am going to merge this as-is, once CI is green (again). |
|
@Jinming-Hu can't wait for you to share the performance numbers on Windows. I have some optimizations in mind that I suspect can get us some improvements, but wanted to see the change first to get a sense of order-of-magnitude. Thanks! |
Fixes #354