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
3fb00b27
Commit
3fb00b27
authored
1 year ago
by
Joe Donofry
Browse files
Options
Downloads
Plain Diff
Merge branch 'verbose_logging' into 'master'
Add client verbose logging support See merge request
!5
parents
d9268930
28d81e47
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!5
Add client verbose logging support
Pipeline
#4829
passed
1 year ago
Stage: build
Stage: deploy
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/coeurl/client.hpp
+8
-0
8 additions, 0 deletions
include/coeurl/client.hpp
lib/client.cpp
+10
-15
10 additions, 15 deletions
lib/client.cpp
lib/errors.cpp
+6
-12
6 additions, 12 deletions
lib/errors.cpp
lib/request.cpp
+7
-5
7 additions, 5 deletions
lib/request.cpp
with
31 additions
and
32 deletions
include/coeurl/client.hpp
+
8
−
0
View file @
3fb00b27
...
...
@@ -141,6 +141,13 @@ struct Client {
/// @sa set_verify_peer
bool
does_verify_peer
()
{
return
this
->
verify_peer_
;
}
//! Set whether or not to log curl requests verbosely.
/// @sa verbose and also CURLOPT_VERBOSE
void
verbose
(
bool
verbose
)
{
this
->
verbose_logging_
=
verbose
;
}
/// @brief Query whether verbose logging is enabled or not
/// @sa verbose(bool)
bool
verbose
()
{
return
this
->
verbose_logging_
;
}
//! Timeout connection after the specified amount of seconds, if the server
//! stops sending acks.
void
connection_timeout
(
long
t
)
{
connection_timeout_
=
t
;
}
...
...
@@ -191,6 +198,7 @@ struct Client {
std
::
atomic
<
bool
>
stopped
{
false
};
std
::
atomic
<
bool
>
prevent_new_requests
{
false
};
bool
verify_peer_
=
true
;
bool
verbose_logging_
=
false
;
long
connection_timeout_
=
0
;
...
...
This diff is collapsed.
Click to expand it.
lib/client.cpp
+
10
−
15
View file @
3fb00b27
...
...
@@ -133,21 +133,16 @@ void Client::cancel_requests_cb(evutil_socket_t, short, void *userp) {
Client
*
g
=
(
Client
*
)
userp
;
// prevent new requests from being added
{
g
->
prevent_new_requests
=
true
;
}
// safe to access now, since we are running on the worker thread and only
// there running_requests is modified
while
(
!
g
->
running_requests
.
empty
())
g
->
remove_request
(
g
->
running_requests
.
back
().
get
());
// prevent new requests from being added
{
g
->
prevent_new_requests
=
true
;
}
// Allow for new requests
{
g
->
prevent_new_requests
=
false
;
}
// safe to access now, since we are running on the worker thread and only
// there running_requests is modified
while
(
!
g
->
running_requests
.
empty
())
g
->
remove_request
(
g
->
running_requests
.
back
().
get
());
// Allow for new requests
{
g
->
prevent_new_requests
=
false
;
}
CURLMcode
rc
=
curl_multi_socket_action
(
g
->
multi
,
CURL_SOCKET_TIMEOUT
,
0
,
&
g
->
still_running
);
mcode_or_die
(
"timer_cb: curl_multi_socket_action"
,
rc
);
...
...
@@ -393,8 +388,8 @@ void Client::delete_(std::string url, std::function<void(const Request &)> callb
this
->
submit_request
(
std
::
move
(
req
));
}
void
Client
::
delete_
(
std
::
string
url
,
std
::
string
request_body
,
std
::
string
mimetype
,
std
::
function
<
void
(
const
Request
&
)
>
callback
,
const
Headers
&
headers
,
long
max_redirects
)
{
void
Client
::
delete_
(
std
::
string
url
,
std
::
string
request_body
,
std
::
string
mimetype
,
std
::
function
<
void
(
const
Request
&
)
>
callback
,
const
Headers
&
headers
,
long
max_redirects
)
{
auto
req
=
std
::
make_shared
<
Request
>
(
this
,
Request
::
Method
::
Delete
,
std
::
move
(
url
));
req
->
request
(
request_body
,
mimetype
);
...
...
This diff is collapsed.
Click to expand it.
lib/errors.cpp
+
6
−
12
View file @
3fb00b27
#include
<coeurl/errors.hpp>
const
char
*
coeurl
::
to_string
(
CURLcode
c
)
{
return
curl_easy_strerror
(
c
);
}
const
char
*
coeurl
::
to_string
(
CURLcode
c
)
{
return
curl_easy_strerror
(
c
);
}
//const char* coeurl::to_string(CURLUcode c) {
// return curl_url_strerror(c);
//}
//
const char* coeurl::to_string(CURLUcode c) {
//
return curl_url_strerror(c);
//
}
const
char
*
coeurl
::
to_string
(
CURLMcode
c
)
{
return
curl_multi_strerror
(
c
);
}
const
char
*
coeurl
::
to_string
(
CURLMcode
c
)
{
return
curl_multi_strerror
(
c
);
}
const
char
*
coeurl
::
to_string
(
CURLSHcode
c
)
{
return
curl_share_strerror
(
c
);
}
const
char
*
coeurl
::
to_string
(
CURLSHcode
c
)
{
return
curl_share_strerror
(
c
);
}
This diff is collapsed.
Click to expand it.
lib/request.cpp
+
7
−
5
View file @
3fb00b27
...
...
@@ -118,20 +118,22 @@ Request::Request(Client *client, Method m, std::string url__) : url_(std::move(u
curl_easy_setopt
(
this
->
easy
,
CURLOPT_WRITEDATA
,
this
);
curl_easy_setopt
(
this
->
easy
,
CURLOPT_HEADERFUNCTION
,
header_cb
);
curl_easy_setopt
(
this
->
easy
,
CURLOPT_HEADERDATA
,
this
);
// curl_easy_setopt(this->easy, CURLOPT_VERBOSE, 1L);
if
(
this
->
global
->
verbose
())
{
curl_easy_setopt
(
this
->
easy
,
CURLOPT_VERBOSE
,
1L
);
}
curl_easy_setopt
(
this
->
easy
,
CURLOPT_ERRORBUFFER
,
this
->
error
);
curl_easy_setopt
(
this
->
easy
,
CURLOPT_PRIVATE
,
this
);
curl_easy_setopt
(
this
->
easy
,
CURLOPT_NOPROGRESS
,
1L
);
curl_easy_setopt
(
this
->
easy
,
CURLOPT_XFERINFOFUNCTION
,
prog_cb
);
curl_easy_setopt
(
this
->
easy
,
CURLOPT_XFERINFODATA
,
this
);
#if CURL_AT_LEAST_VERSION(7, 85, 0)
#if CURL_AT_LEAST_VERSION(7, 85, 0)
curl_easy_setopt
(
this
->
easy
,
CURLOPT_PROTOCOLS_STR
,
"HTTPS,HTTP"
);
#else
#else
curl_easy_setopt
(
this
->
easy
,
CURLOPT_PROTOCOLS
,
CURLPROTO_HTTP
|
CURLPROTO_HTTPS
);
#endif
#endif
// 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_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
...
...
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