From f66e1240b628ebe3a33acc140c903d379efcf58d Mon Sep 17 00:00:00 2001 From: Francisc Balint <7178547+franciscbalint@users.noreply.github.com> Date: Thu, 20 Aug 2026 00:41:24 +0400 Subject: [PATCH] Set cpr request timeouts on API calls. Cap HTTP requests at 120s so a stalled ZeroBounce endpoint cannot hang the caller. --- README.md | 7 +++++++ include/ZeroBounce/ZeroBounce.h | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e3a3f79..6a25e1f 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,13 @@ This API wrapper contains methods for interacting easily with ZeroBounce API. More information about ZeroBounce you can find in the [official documentation](https://www.zerobounce.net/docs/). + +## Security + +- Keep API keys on a trusted server. Do not embed them in mobile apps or browser JavaScript that untrusted users can inspect. +- Custom API base URLs (when supported) must use `https://`. Do not pass end-user-controlled hosts into those settings. +- Request URLs include `api_key` as a query parameter (ZeroBounce API contract). Do not log full request URLs or enable payload debug logging in production. + ## INSTALLATION Before installing the wrapper, you have to make sure that `CMake` is installed on your system. It can be downloaded from [here](https://cmake.org/download/). diff --git a/include/ZeroBounce/ZeroBounce.h b/include/ZeroBounce/ZeroBounce.h index c8e334e..caca8b0 100644 --- a/include/ZeroBounce/ZeroBounce.h +++ b/include/ZeroBounce/ZeroBounce.h @@ -95,19 +95,19 @@ class BaseRequestHandler { class RequestHandler : public BaseRequestHandler { protected: cpr::Response doGet(const cpr::Url& url) { - return cpr::Get(url); + return cpr::Get(url, cpr::Timeout{120000}); } cpr::Response doGet(const cpr::Url& url, const cpr::Header& header) { - return cpr::Get(url, header); + return cpr::Get(url, header, cpr::Timeout{120000}); } cpr::Response doGetWithParameters(const cpr::Url& url, const cpr::Parameters& parameters) { - return cpr::Get(url, parameters); + return cpr::Get(url, parameters, cpr::Timeout{120000}); } cpr::Response doPost(const cpr::Url& url, const cpr::Header& header, const cpr::Body& body) { - return cpr::Post(url, header, body); + return cpr::Post(url, header, body, cpr::Timeout{120000}); } cpr::Response doPost(const cpr::Url& url, const cpr::Header& header, const cpr::Multipart& multipart) { - return cpr::Post(url, header, multipart); + return cpr::Post(url, header, multipart, cpr::Timeout{120000}); } };