Repository navigation
Add the transport seam and the libcurl default (T10) #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
23f2c31
Add the transport seam and the libcurl default (T10)
kirre-bylund f03015a
Install curl on Windows in CI
kirre-bylund 18a6e99
Fix the five review findings on the transport
kirre-bylund 5ef9a94
Remove a duplicated LOOTLOCKER_BUILD_EXAMPLES option
kirre-bylund 71a3ebc
Document the transport in the README
kirre-bylund 872ced1
Make the injection seams weak_ptr instead of raw pointers
kirre-bylund 1da3512
Stop following redirects: they leak the session token
kirre-bylund File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,4 @@ out/ | |
| *.user | ||
| CMakeUserPresets.json | ||
| *.obj | ||
| CMakeFiles/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| #pragma once | ||
|
|
||
| // The libcurl transport (D3). | ||
| // | ||
| // Only compiled when libcurl is found, because a console adopter injects its own transport | ||
| // and must not be forced to build curl. `LOOTLOCKER_HAVE_CURL` is defined by CMake when | ||
| // the dependency is present; without it this header declares nothing and the SDK still | ||
| // builds. | ||
| // | ||
| // The implementation is `curl_multi`, which is already pollable: `Start` adds an easy | ||
| // handle to the multi handle, `Poll` drives it without waiting, and `Cancel` removes it. | ||
| // That is why D3 chose curl - the interface shape is the library's native shape rather | ||
| // than something bolted on. | ||
|
|
||
| #include <lootlocker/http_transport.h> | ||
|
|
||
| #if defined(LOOTLOCKER_HAVE_CURL) | ||
|
|
||
| #include <cstdint> | ||
| #include <map> | ||
| #include <string> | ||
|
|
||
| namespace lootlocker { | ||
|
|
||
| class CurlHttpTransport : public IHttpTransport { | ||
| public: | ||
| CurlHttpTransport(); | ||
| ~CurlHttpTransport() override; | ||
|
|
||
| // Not copyable: it owns a curl multi handle and per-transfer state. | ||
| CurlHttpTransport(const CurlHttpTransport&) = delete; | ||
| CurlHttpTransport& operator=(const CurlHttpTransport&) = delete; | ||
|
|
||
| TransferId Start(const Request& request) override; | ||
| bool Poll(TransferId id, Response& out) override; | ||
| void Cancel(TransferId id) override; | ||
|
|
||
| // True when a transfer died at the curl level rather than returning a status. Exposed | ||
| // so a test can distinguish "no response yet" from "the transfer failed". | ||
| bool HadTransportError() const { return m_had_transport_error; } | ||
|
|
||
| private: | ||
| struct Transfer; | ||
|
|
||
| // Drives the multi handle once. Called from `Poll`, never blocks. | ||
| void Pump(); | ||
|
|
||
| void* m_multi = nullptr; // CURLM*, void* so curl headers stay out of this header | ||
| TransferId m_next_id = 0; | ||
| std::map<TransferId, Transfer*> m_transfers; | ||
| bool m_had_transport_error = false; | ||
| }; | ||
|
|
||
| } // namespace lootlocker | ||
|
|
||
| #endif // LOOTLOCKER_HAVE_CURL |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.