Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
coeurl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nheko Reborn
coeurl
Commits
d97acd1a
Verified
Commit
d97acd1a
authored
2 years ago
by
Nicolas Werner
Browse files
Options
Downloads
Patches
Plain Diff
Add altsvc support
This allows the connection to discover http/3 ports.
parent
cfeae3ac
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#3942
failed
2 years ago
Stage: build
Stage: deploy
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CMakeLists.txt
+1
-1
1 addition, 1 deletion
CMakeLists.txt
include/coeurl/client.hpp
+9
-1
9 additions, 1 deletion
include/coeurl/client.hpp
lib/request.cpp
+5
-0
5 additions, 0 deletions
lib/request.cpp
meson.build
+1
-1
1 addition, 1 deletion
meson.build
with
16 additions
and
3 deletions
CMakeLists.txt
+
1
−
1
View file @
d97acd1a
...
...
@@ -26,7 +26,7 @@ option(USE_BUNDLED_SPDLOG "Use the bundled version of spdlog." ${HUNTER_ENABLED}
project
(
coeurl
VERSION 0.
2.1
VERSION 0.
3.0
DESCRIPTION
"Simple library to do http requests asynchronously via CURL in C++."
HOMEPAGE_URL
"https://nheko.im/nheko-reborn/cocurl"
)
...
...
This diff is collapsed.
Click to expand it.
include/coeurl/client.hpp
+
9
−
1
View file @
d97acd1a
...
...
@@ -27,7 +27,7 @@ struct SockInfo;
//! Global information, common to all connections
struct
Client
{
//! construct a new client
//! construct a new client
. For http/3 support, set the alt_svc_cache_path as well.
Client
();
/// @brief cleans up a client
/// Implicitly closes the connection and blocks until all of them exited.
...
...
@@ -151,6 +151,12 @@ struct Client {
//! Default is 8.
void
maximum_connections_per_host
(
long
count
);
//! Cache alternative service entries. This allows automatically switching to http/3.
//! Usually you provide a path in `~/.cache` or similar.
void
alt_svc_cache_path
(
const
std
::
string
&
path
)
{
alt_svc_cache_path_
=
path
;
}
//! Where alternate svc entries are cached. Usually in `~/.cache`.
const
std
::
string
&
alt_svc_cache_path
()
const
{
return
alt_svc_cache_path_
;
}
private
:
// Call this to run the event loop. Will block until the client is shutdown.
void
run
();
...
...
@@ -196,6 +202,8 @@ struct Client {
std
::
thread
bg_thread
;
std
::
string
alt_svc_cache_path_
;
friend
Request
;
};
}
// namespace coeurl
This diff is collapsed.
Click to expand it.
lib/request.cpp
+
5
−
0
View file @
d97acd1a
...
...
@@ -125,6 +125,11 @@ Request::Request(Client *client, Method m, std::string url__) : url_(std::move(u
curl_easy_setopt
(
this
->
easy
,
CURLOPT_XFERINFOFUNCTION
,
prog_cb
);
curl_easy_setopt
(
this
->
easy
,
CURLOPT_XFERINFODATA
,
this
);
curl_easy_setopt
(
this
->
easy
,
CURLOPT_PROTOCOLS
,
CURLPROTO_HTTP
|
CURLPROTO_HTTPS
);
// enable altsvc support, which allows us to switch to http3
curl_easy_setopt
(
this
->
easy
,
CURLOPT_ALTSVC_CTRL
,
CURLALTSVC_H1
|
CURLALTSVC_H2
|
CURLALTSVC_H3
);
curl_easy_setopt
(
this
->
easy
,
CURLOPT_ALTSVC
,
client
->
alt_svc_cache_path
().
c_str
());
// default to all supported encodings
curl_easy_setopt
(
this
->
easy
,
CURLOPT_ACCEPT_ENCODING
,
""
);
...
...
This diff is collapsed.
Click to expand it.
meson.build
+
1
−
1
View file @
d97acd1a
project
(
'coeurl'
,
'cpp'
,
version
:
'0.
2.1
'
,
version
:
'0.
3.0
'
,
license
:
'MIT'
,
meson_version
:
'>=0.54'
,
default_options
:
[
'warning_level=3'
,
'cpp_std=c++17'
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment