Skip to content
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

Preperation For 1.9.8 Release #1116

Open
wants to merge 6 commits into
base: 1.9.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ Checks: '*,
-modernize-return-braced-init-list,
-cppcoreguidelines-avoid-magic-numbers,
-readability-magic-numbers,
-cppcoreguidelines-avoid-do-while
-cppcoreguidelines-avoid-do-while,
-cppcoreguidelines-rvalue-reference-param-not-moved,
-misc-header-include-cycle
'
WarningsAsErrors: '*'
HeaderFilterRegex: 'src/*.hpp'
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ jobs:
steps:
- name: Update package list
run: sudo dnf update -y
- name: Install dependencies
run: sudo dnf install -y openssl-devel cmake git gcc clang ninja-build
- name: Install clang-tidy
- name: Install clang-format
run: sudo dnf install -y clang-tools-extra
- name: Checkout
uses: actions/checkout@v3
- name: Check format
uses: RafikFarhad/[email protected]
run: bash scripts/check_clang_format.sh
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ _site/
.ycm_extra_conf.py*

# VSCode
.vscode/
.vscode/*
!.vscode/tasks.json
.vs/
!.vs/tasks.json

# clangd
.cache/
Expand Down
62 changes: 62 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "🗑️ Delete build dir",
"type": "shell",
"command": "${workspaceFolder}/scripts/delete_build_dir.sh",
"problemMatcher": [],
"group": {
"kind": "build"
},
"presentation": {
"clear": true
},
"options": {
"cwd": "${workspaceFolder}"
}
},
{
"label": "📝 Run clang-format",
"type": "shell",
"command": "${workspaceFolder}/scripts/run_clang_format.sh",
"args": [
"cpr",
"include",
"test"
],
"problemMatcher": [],
"group": {
"kind": "build"
},
"presentation": {
"clear": true
},
"options": {
"cwd": "${workspaceFolder}"
}
},
{
"label": "📑 Check clang-format",
"type": "shell",
"command": "${workspaceFolder}/scripts/check_clang_format.sh",
"args": [
"cpr",
"include",
"test"
],
"problemMatcher": [],
"group": {
"kind": "build"
},
"presentation": {
"clear": true
},
"options": {
"cwd": "${workspaceFolder}"
}
}
]
}
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.15)
project(cpr VERSION 1.9.7 LANGUAGES CXX)
project(cpr VERSION 1.9.8 LANGUAGES CXX)

math(EXPR cpr_VERSION_NUM "${cpr_VERSION_MAJOR} * 0x10000 + ${cpr_VERSION_MINOR} * 0x100 + ${cpr_VERSION_PATCH}" OUTPUT_FORMAT HEXADECIMAL)
configure_file("${cpr_SOURCE_DIR}/cmake/cprver.h.in" "${cpr_BINARY_DIR}/cpr_generated_includes/cpr/cprver.h")
Expand Down Expand Up @@ -232,8 +232,8 @@ else()
clear_variable(DESTINATION CMAKE_CXX_CLANG_TIDY BACKUP CMAKE_CXX_CLANG_TIDY_BKP)

FetchContent_Declare(curl
URL https://github.com/curl/curl/releases/download/curl-8_4_0/curl-8.4.0.tar.xz
URL_HASH SHA256=16c62a9c4af0f703d28bda6d7bbf37ba47055ad3414d70dec63e2e6336f2a82d # the file hash for curl-8.4.0.tar.xz
URL https://github.com/curl/curl/releases/download/curl-8_10_1/curl-8.10.1.tar.xz
URL_HASH SHA256=73a4b0e99596a09fa5924a4fb7e4b995a85fda0d18a2c02ab9cf134bebce04ee # the file hash for curl-8.10.1.tar.xz
USES_TERMINAL_DOWNLOAD TRUE) # <---- This is needed only for Ninja to show download progress
FetchContent_MakeAvailable(curl)

Expand Down
2 changes: 0 additions & 2 deletions cpr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ add_library(cpr
curlholder.cpp
error.cpp
multipart.cpp
parameters.cpp
payload.cpp
proxies.cpp
proxyauth.cpp
session.cpp
Expand Down
3 changes: 3 additions & 0 deletions cpr/accept_encoding.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include "cpr/accept_encoding.h"

#include <algorithm>
#include <initializer_list>
#include <iterator>
#include <numeric>
#include <string>
#include <utility>

namespace cpr {

Expand Down
1 change: 1 addition & 0 deletions cpr/bearer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "cpr/bearer.h"
#include "cpr/util.h"
#include <curl/curlver.h>

namespace cpr {
// Only supported with libcurl >= 7.61.0.
Expand Down
2 changes: 2 additions & 0 deletions cpr/cert_info.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "cpr/cert_info.h"
#include <cstddef>
#include <string>

namespace cpr {

Expand Down
4 changes: 4 additions & 0 deletions cpr/cookies.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include "cpr/cookies.h"
#include "cpr/curlholder.h"
#include <chrono>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <string>

namespace cpr {
const std::string Cookie::GetDomain() const {
Expand Down
1 change: 1 addition & 0 deletions cpr/cprtypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <algorithm>
#include <cctype>
#include <string>

namespace cpr {
bool CaseInsensitiveCompare::operator()(const std::string& a, const std::string& b) const noexcept {
Expand Down
3 changes: 3 additions & 0 deletions cpr/curl_container.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "cpr/curl_container.h"
#include "cpr/curlholder.h"
#include <algorithm>
#include <initializer_list>
#include <iterator>
#include <string>


namespace cpr {
Expand Down
3 changes: 3 additions & 0 deletions cpr/curlholder.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "cpr/curlholder.h"
#include <cassert>
#include <curl/curl.h>
#include <curl/easy.h>
#include <string>

namespace cpr {
CurlHolder::CurlHolder() {
Expand Down
2 changes: 2 additions & 0 deletions cpr/error.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "cpr/error.h"

#include <cstdint>
#include <curl/curl.h>
#include <curl/curlver.h>

namespace cpr {
ErrorCode Error::getErrorCodeForCurlError(std::int32_t curl_code) {
Expand Down
6 changes: 5 additions & 1 deletion cpr/interceptor.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include "cpr/interceptor.h"
#include "cpr/callback.h"
#include "cpr/response.h"
#include "cpr/session.h"

#include <fstream>

#include <exception>

namespace cpr {

Expand Down
1 change: 1 addition & 0 deletions cpr/multipart.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "cpr/multipart.h"
#include <initializer_list>

namespace cpr {
Multipart::Multipart(const std::initializer_list<Part>& p_parts) : parts{p_parts} {}
Expand Down
4 changes: 0 additions & 4 deletions cpr/parameters.cpp

This file was deleted.

4 changes: 0 additions & 4 deletions cpr/payload.cpp

This file was deleted.

1 change: 1 addition & 0 deletions cpr/redirect.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "cpr/redirect.h"
#include <cstdint>

namespace cpr {
PostRedirectFlags operator|(PostRedirectFlags lhs, PostRedirectFlags rhs) {
Expand Down
17 changes: 16 additions & 1 deletion cpr/response.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
#include "cpr/response.h"
#include <cassert>
#include <memory>
#include <string>
#include <utility>
#include <vector>

#include "cpr/cert_info.h"
#include "cpr/cookies.h"
#include "cpr/cprtypes.h"
#include "cpr/curlholder.h"
#include "cpr/error.h"
#include "cpr/util.h"

#include <curl/curl.h>
#include <curl/curlver.h>

namespace cpr {

Expand All @@ -11,7 +26,7 @@ Response::Response(std::shared_ptr<CurlHolder> curl, std::string&& p_text, std::
char* url_string{nullptr};
curl_easy_getinfo(curl_->handle, CURLINFO_EFFECTIVE_URL, &url_string);
url = Url(url_string);
#if LIBCURL_VERSION_NUM >= 0x073700 // 7.55.0
#if LIBCURL_VERSION_NUM >= 0x073700 // 7.55.0
curl_easy_getinfo(curl_->handle, CURLINFO_SIZE_DOWNLOAD_T, &downloaded_bytes);
curl_easy_getinfo(curl_->handle, CURLINFO_SIZE_UPLOAD_T, &uploaded_bytes);
#else
Expand Down
43 changes: 36 additions & 7 deletions cpr/session.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,47 @@
#include "cpr/session.h"

#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <memory>
#include <stdexcept>
#include <string>
#include <utility>

#include <curl/curl.h>
#include <curl/curlver.h>
#include <curl/easy.h>

#include "cpr/async.h"
#include "cpr/auth.h"
#include "cpr/bearer.h"
#include "cpr/body.h"
#include "cpr/callback.h"
#include "cpr/connect_timeout.h"
#include "cpr/cookies.h"
#include "cpr/cprtypes.h"
#include "cpr/curlholder.h"
#include "cpr/http_version.h"
#include "cpr/interceptor.h"
#include "cpr/interface.h"
#include "cpr/limit_rate.h"
#include "cpr/local_port.h"
#include "cpr/local_port_range.h"
#include "cpr/low_speed.h"
#include "cpr/multipart.h"
#include "cpr/payload.h"
#include "cpr/range.h"
#include "cpr/redirect.h"
#include "cpr/reserve_size.h"
#include "cpr/response.h"
#include "cpr/ssl_options.h"
#include "cpr/timeout.h"
#include "cpr/unix_socket.h"
#include "cpr/user_agent.h"
#include "cpr/util.h"
#include "cpr/verbose.h"

#if SUPPORT_CURLOPT_SSL_CTX_FUNCTION
#include "cpr/ssl_ctx.h"
Expand Down Expand Up @@ -137,9 +165,10 @@ Response Session::makeDownloadRequest() {
curl_easy_getinfo(curl_->handle, CURLINFO_COOKIELIST, &raw_cookies);
Cookies cookies = util::parseCookies(raw_cookies);
curl_slist_free_all(raw_cookies);

std::string errorMsg = curl_->error.data();

return Response(curl_, "", std::move(header_string), std::move(cookies), Error(curl_error, std::move(errorMsg)));
return Response(curl_, "", std::move(header_string_), std::move(cookies), Error(curl_error, std::move(errorMsg)));
}

void Session::prepareCommon() {
Expand Down Expand Up @@ -326,14 +355,14 @@ void Session::SetUserAgent(const UserAgent& ua) {
void Session::SetPayload(const Payload& payload) {
hasBodyOrPayload_ = true;
const std::string content = payload.GetContent(*curl_);
curl_easy_setopt(curl_->handle, CURLOPT_POSTFIELDSIZE_LARGE, static_cast<curl_off_t>(content.length()));
curl_easy_setopt(curl_->handle, CURLOPT_POSTFIELDSIZE_LARGE, static_cast<cpr_pf_arg_t>(content.length()));
curl_easy_setopt(curl_->handle, CURLOPT_COPYPOSTFIELDS, content.c_str());
}

void Session::SetPayload(Payload&& payload) {
hasBodyOrPayload_ = true;
const std::string content = payload.GetContent(*curl_);
curl_easy_setopt(curl_->handle, CURLOPT_POSTFIELDSIZE_LARGE, static_cast<curl_off_t>(content.length()));
curl_easy_setopt(curl_->handle, CURLOPT_POSTFIELDSIZE_LARGE, static_cast<cpr_pf_arg_t>(content.length()));
curl_easy_setopt(curl_->handle, CURLOPT_COPYPOSTFIELDS, content.c_str());
}

Expand Down Expand Up @@ -425,13 +454,13 @@ void Session::SetCookies(const Cookies& cookies) {

void Session::SetBody(const Body& body) {
hasBodyOrPayload_ = true;
curl_easy_setopt(curl_->handle, CURLOPT_POSTFIELDSIZE_LARGE, static_cast<curl_off_t>(body.str().length()));
curl_easy_setopt(curl_->handle, CURLOPT_POSTFIELDSIZE_LARGE, static_cast<cpr_pf_arg_t>(body.str().length()));
curl_easy_setopt(curl_->handle, CURLOPT_POSTFIELDS, body.c_str());
}

void Session::SetBody(Body&& body) {
hasBodyOrPayload_ = true;
curl_easy_setopt(curl_->handle, CURLOPT_POSTFIELDSIZE_LARGE, static_cast<curl_off_t>(body.str().length()));
curl_easy_setopt(curl_->handle, CURLOPT_POSTFIELDSIZE_LARGE, static_cast<cpr_pf_arg_t>(body.str().length()));
curl_easy_setopt(curl_->handle, CURLOPT_COPYPOSTFIELDS, body.c_str());
}

Expand Down
11 changes: 8 additions & 3 deletions cpr/ssl_ctx.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@

#include "cpr/ssl_ctx.h"
#include "cpr/ssl_options.h"
#include <cstdio>
#include <curl/curl.h>

#if SUPPORT_CURLOPT_SSL_CTX_FUNCTION

#ifdef OPENSSL_BACKEND_USED

#include <openssl/err.h>
#include <openssl/safestack.h>
#include <openssl/bio.h>
#include <openssl/pem.h>
#include <openssl/ssl.h>
#include <openssl/types.h>
#include <openssl/x509.h>
#include <openssl/x509_vfy.h>

namespace cpr {

Expand Down
6 changes: 6 additions & 0 deletions cpr/threadpool.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#include "cpr/threadpool.h"
#include <chrono>
#include <ctime>
#include <memory>
#include <mutex>
#include <thread>
#include <utility>

namespace cpr {

Expand Down
1 change: 1 addition & 0 deletions cpr/timeout.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "cpr/timeout.h"

#include <chrono>
#include <limits>
#include <stdexcept>
#include <string>
Expand Down
Loading
Loading