{"id":19374792,"url":"https://github.com/malwarebo/blaze","last_synced_at":"2025-10-24T00:57:59.544Z","repository":{"id":181376963,"uuid":"664537938","full_name":"malwarebo/blaze","owner":"malwarebo","description":" C++ http library","archived":false,"fork":false,"pushed_at":"2025-04-01T10:48:25.000Z","size":43,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-01T11:33:09.757Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/malwarebo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-10T07:48:01.000Z","updated_at":"2025-04-01T10:48:28.000Z","dependencies_parsed_at":"2024-01-26T16:55:34.919Z","dependency_job_id":"d4f5b07b-8eaf-4193-a533-7bad6b8eb5ee","html_url":"https://github.com/malwarebo/blaze","commit_stats":null,"previous_names":["malwarebo/blaze","kbww/blaze"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/malwarebo/blaze","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malwarebo%2Fblaze","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malwarebo%2Fblaze/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malwarebo%2Fblaze/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malwarebo%2Fblaze/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/malwarebo","download_url":"https://codeload.github.com/malwarebo/blaze/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malwarebo%2Fblaze/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259843329,"owners_count":22920311,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T08:36:08.828Z","updated_at":"2025-10-24T00:57:59.530Z","avatar_url":"https://github.com/malwarebo.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# blaze\n\nA modern, comprehensive, and high-performance C++ HTTP client library built on top of libcurl. Designed for production use with enterprise-grade features including connection pooling, authentication, streaming, monitoring, and advanced error handling.\n\n## Features\n\n- **High Performance**: Connection pooling, compression, keep-alive\n- **Security**: SSL/TLS configuration, multiple authentication methods\n- **Developer Friendly**: Builder pattern, fluent API, comprehensive error handling\n- **Monitoring**: Request metrics, logging, progress tracking\n- **Reliability**: Retry logic with exponential backoff\n- **Streaming**: Response streaming for large data\n- **Flexible**: Interceptors, custom configuration, proxy support\n- **Utilities**: URL encoding, Base64, query string parsing\n\n## Requirements\n\n- C++17 compatible compiler (GCC 7+, Clang 5+, MSVC 2017+)\n- CMake 3.14 or higher\n- libcurl development files\n- Google Test (for testing, optional)\n\n### Installing Dependencies\n\n#### Ubuntu/Debian\n\n```bash\nsudo apt-get update\nsudo apt-get install build-essential cmake libcurl4-openssl-dev\n```\n\n#### Fedora\n\n```bash\nsudo dnf install gcc-c++ cmake libcurl-devel\n```\n\n#### macOS\n\n```bash\nbrew install cmake curl\n```\n\n#### Windows\n\nInstall [vcpkg](https://github.com/Microsoft/vcpkg) and then:\n\n```bash\nvcpkg install curl:x64-windows\n```\n\n## Building\n\n```bash\n# Clone the repository\ngit clone https://github.com/your-repo/blaze.git\ncd blaze\n\n# Create build directory\nmkdir build \u0026\u0026 cd build\n\n# Configure and build\ncmake ..\nmake -j4\n\n# Run tests (optional)\n./blaze_tests\n\n# Run comprehensive example\n./blaze_example\n```\n\n## Quick Start\n\n### Basic GET Request\n\n```cpp\n#include \u003cblaze/http_client.hpp\u003e\n#include \u003ciostream\u003e\n\nint main() {\n    blaze::HttpClient client;\n    \n    auto response = client.get(\"https://api.example.com/data\");\n    \n    if (response.isSuccess()) {\n        std::cout \u003c\u003c \"Status: \" \u003c\u003c response.status_code \u003c\u003c std::endl;\n        std::cout \u003c\u003c \"Body: \" \u003c\u003c response.body \u003c\u003c std::endl;\n        std::cout \u003c\u003c \"Request took: \" \u003c\u003c response.metrics.total_time.count() \u003c\u003c \"ms\" \u003c\u003c std::endl;\n    } else {\n        std::cerr \u003c\u003c \"Error: \" \u003c\u003c response.error_message \u003c\u003c std::endl;\n    }\n}\n```\n\n### Builder Pattern (Recommended)\n\n```cpp\nauto response = blaze::HttpClient::builder()\n    .url(\"https://api.example.com/users\")\n    .method(\"POST\")\n    .jsonBody(R\"({\"name\": \"John\", \"email\": \"john@example.com\"})\")\n    .bearerToken(\"your-auth-token\")\n    .timeout(5000)\n    .enableMetrics()\n    .send();\n\nif (response.isSuccess()) {\n    std::cout \u003c\u003c \"User created successfully!\" \u003c\u003c std::endl;\n}\n```\n\n## Examples\n\n### Authentication\n\n#### Basic Authentication\n```cpp\nblaze::HttpClient client;\nclient.setBasicAuth(\"username\", \"password\");\nauto response = client.get(\"https://api.example.com/protected\");\n```\n\n#### Bearer Token\n```cpp\nauto response = blaze::HttpClient::builder()\n    .url(\"https://api.example.com/data\")\n    .bearerToken(\"your-jwt-token\")\n    .send();\n```\n\n#### API Key\n```cpp\nblaze::HttpClient client;\nclient.setApiKey(\"your-api-key\", \"X-API-Key\");\nauto response = client.get(\"https://api.example.com/data\");\n```\n\n### Streaming Large Responses\n\n```cpp\nblaze::HttpRequest request;\nrequest.url = \"https://api.example.com/large-dataset\";\n\nsize_t total_received = 0;\nauto response = client.streamResponse(request, [\u0026](const char* data, size_t size) {\n    // Process data chunk\n    total_received += size;\n    std::cout \u003c\u003c \"Received: \" \u003c\u003c total_received \u003c\u003c \" bytes\\r\" \u003c\u003c std::flush;\n    \n    // Return false to cancel stream\n    return total_received \u003c 10 * 1024 * 1024; // Stop at 10MB\n});\n```\n\n### Progress Tracking\n\n```cpp\nauto response = client.sendWithProgress(request, [](size_t downloaded, size_t total) {\n    if (total \u003e 0) {\n        double percent = (double)downloaded / total * 100.0;\n        std::cout \u003c\u003c \"Progress: \" \u003c\u003c std::fixed \u003c\u003c std::setprecision(1) \n                  \u003c\u003c percent \u003c\u003c \"%\\r\" \u003c\u003c std::flush;\n    }\n    return true; // Continue download\n});\n```\n\n### Advanced Configuration\n\n```cpp\nblaze::HttpConfig config;\nconfig.timeout_ms = 30000;\nconfig.connect_timeout_ms = 5000;\nconfig.max_response_size = 100 * 1024 * 1024; // 100MB\nconfig.enable_compression = true;\nconfig.keep_alive = true;\nconfig.max_connections = 10;\n\n// SSL Configuration\nconfig.ssl.verify_peer = true;\nconfig.ssl.ca_cert_path = \"/path/to/ca-cert.pem\";\n\n// Retry Configuration\nconfig.retry.max_attempts = 3;\nconfig.retry.initial_delay = std::chrono::milliseconds(1000);\nconfig.retry.backoff_multiplier = 2.0;\n\n// Proxy Configuration\nconfig.proxy.enabled = true;\nconfig.proxy.url = \"http://proxy.company.com:8080\";\nconfig.proxy.username = \"proxy_user\";\nconfig.proxy.password = \"proxy_pass\";\n\nblaze::HttpClient client(config);\n```\n\n### Request/Response Interceptors\n\n```cpp\nblaze::HttpClient client;\n\n// Add request interceptor\nclient.addRequestInterceptor([](blaze::HttpRequest\u0026 req) {\n    req.headers[\"X-Request-ID\"] = blaze::utils::generateRequestId();\n    req.headers[\"X-Timestamp\"] = std::to_string(std::time(nullptr));\n});\n\n// Add response interceptor\nclient.addResponseInterceptor([](blaze::HttpResponse\u0026 resp) {\n    std::cout \u003c\u003c \"Response received: \" \u003c\u003c resp.status_code \n              \u003c\u003c \" (\" \u003c\u003c resp.metrics.total_time.count() \u003c\u003c \"ms)\" \u003c\u003c std::endl;\n});\n```\n\n### File Operations\n\n#### Upload File\n```cpp\nauto response = client.uploadFile(\n    \"https://api.example.com/upload\",\n    \"/path/to/file.jpg\",\n    \"file\", // form field name\n    {{\"Authorization\", \"Bearer token\"}}\n);\n```\n\n#### Download File\n```cpp\nauto response = client.downloadFile(\n    \"https://api.example.com/download/file.zip\",\n    \"/path/to/save/file.zip\"\n);\n```\n\n### Error Handling with Status Code Helpers\n\n```cpp\nauto response = client.get(\"https://api.example.com/data\");\n\nif (response.isSuccess()) {\n    // 2xx status codes\n    std::cout \u003c\u003c \"Success: \" \u003c\u003c response.body \u003c\u003c std::endl;\n} else if (response.isClientError()) {\n    // 4xx status codes\n    std::cerr \u003c\u003c \"Client error: \" \u003c\u003c response.status_code \u003c\u003c std::endl;\n} else if (response.isServerError()) {\n    // 5xx status codes\n    std::cerr \u003c\u003c \"Server error: \" \u003c\u003c response.status_code \u003c\u003c std::endl;\n} else {\n    // Network or other errors\n    std::cerr \u003c\u003c \"Network error: \" \u003c\u003c response.error_message \u003c\u003c std::endl;\n    std::cerr \u003c\u003c \"Error type: \" \u003c\u003c static_cast\u003cint\u003e(response.error_type) \u003c\u003c std::endl;\n}\n```\n\n### Utility Functions\n\n```cpp\n// URL encoding/decoding\nstd::string encoded = blaze::utils::urlEncode(\"Hello World!\");\nstd::string decoded = blaze::utils::urlDecode(\"Hello%20World%21\");\n\n// Base64 encoding/decoding\nstd::string base64 = blaze::utils::base64Encode(\"Hello World!\");\nstd::string original = blaze::utils::base64Decode(base64);\n\n// Query string handling\nauto params = blaze::utils::parseQueryString(\"key1=value1\u0026key2=value2\");\nstd::string query = blaze::utils::buildQueryString({{\"key\", \"value\"}, {\"foo\", \"bar\"}});\n\n// URL validation\nbool valid = blaze::utils::isValidUrl(\"https://example.com\");\n\n// Generate request ID\nstd::string id = blaze::utils::generateRequestId();\n```\n\n## API Reference\n\n### HttpClient Class\n\n```cpp\nnamespace blaze {\nclass HttpClient {\npublic:\n    // Constructors\n    HttpClient();\n    explicit HttpClient(const HttpConfig\u0026 config);\n    ~HttpClient();\n    \n    // HTTP Methods\n    HttpResponse get(const std::string\u0026 url, const Headers\u0026 headers = {});\n    HttpResponse post(const std::string\u0026 url, const std::string\u0026 body, const Headers\u0026 headers = {});\n    HttpResponse put(const std::string\u0026 url, const std::string\u0026 body, const Headers\u0026 headers = {});\n    HttpResponse patch(const std::string\u0026 url, const std::string\u0026 body, const Headers\u0026 headers = {});\n    HttpResponse del(const std::string\u0026 url, const Headers\u0026 headers = {});\n    HttpResponse head(const std::string\u0026 url, const Headers\u0026 headers = {});\n    HttpResponse options(const std::string\u0026 url, const Headers\u0026 headers = {});\n    \n    // Advanced Methods\n    HttpResponse send(const HttpRequest\u0026 request);\n    std::future\u003cHttpResponse\u003e sendAsync(const HttpRequest\u0026 request);\n    HttpResponse sendWithProgress(const HttpRequest\u0026 request, ProgressCallback callback);\n    HttpResponse streamResponse(const HttpRequest\u0026 request, StreamCallback callback);\n    \n    // File Operations\n    HttpResponse uploadFile(const std::string\u0026 url, const std::string\u0026 file_path,\n                           const std::string\u0026 field_name = \"file\", const Headers\u0026 headers = {});\n    HttpResponse downloadFile(const std::string\u0026 url, const std::string\u0026 file_path,\n                             const Headers\u0026 headers = {});\n    \n    // Configuration\n    void setConfig(const HttpConfig\u0026 config);\n    HttpConfig getConfig() const;\n    void setDefaultHeader(const std::string\u0026 name, const std::string\u0026 value);\n    void removeDefaultHeader(const std::string\u0026 name);\n    void setTimeout(int timeout_ms);\n    void setUserAgent(const std::string\u0026 user_agent);\n    \n    // Authentication\n    void setBasicAuth(const std::string\u0026 username, const std::string\u0026 password);\n    void setBearerToken(const std::string\u0026 token);\n    void setApiKey(const std::string\u0026 key, const std::string\u0026 header = \"X-API-Key\");\n    void clearAuth();\n    \n    // SSL/TLS\n    void setSSLVerification(bool verify_peer, bool verify_host = true);\n    void setSSLCACert(const std::string\u0026 ca_cert_path);\n    void setSSLClientCert(const std::string\u0026 cert_path, const std::string\u0026 key_path);\n    \n    // Proxy\n    void setProxy(const ProxyConfig\u0026 proxy);\n    void clearProxy();\n    \n    // Retry \u0026 Resilience\n    void enableRetry(int max_attempts = 3);\n    void disableRetry();\n    \n    // Interceptors\n    void addRequestInterceptor(RequestInterceptor interceptor);\n    void addResponseInterceptor(ResponseInterceptor interceptor);\n    void clearInterceptors();\n    \n    // Monitoring\n    void setLogLevel(LogLevel level);\n    void setLogCallback(LogCallback callback);\n    HttpMetrics getConnectionMetrics() const;\n    void resetMetrics();\n    \n    // Static Builder\n    static HttpClientBuilder builder();\n};\n}\n```\n\n### Key Structures\n\n#### HttpResponse\n```cpp\nstruct HttpResponse {\n    int status_code{0};\n    std::map\u003cstd::string, std::string\u003e headers;\n    std::string body;\n    bool success{false};\n    std::string error_message;\n    ErrorType error_type{ErrorType::None};\n    HttpMetrics metrics;\n    std::string request_id;\n    \n    // Helper methods\n    bool isSuccess() const;      // 2xx\n    bool isRedirect() const;     // 3xx\n    bool isClientError() const;  // 4xx\n    bool isServerError() const;  // 5xx\n    bool isHttpError() const;    // 4xx or 5xx\n};\n```\n\n#### HttpRequest\n```cpp\nstruct HttpRequest {\n    std::string url;\n    std::string method{\"GET\"};\n    std::map\u003cstd::string, std::string\u003e headers;\n    std::string body;\n    std::optional\u003cint\u003e timeout_ms;\n    std::optional\u003cbool\u003e follow_redirects;\n    std::optional\u003cint\u003e max_redirects;\n    std::optional\u003cAuth\u003e auth;\n    std::string request_id;\n    bool enable_metrics{true};\n};\n```\n\n#### HttpMetrics\n```cpp\nstruct HttpMetrics {\n    std::chrono::milliseconds total_time{0};\n    std::chrono::milliseconds connect_time{0};\n    std::chrono::milliseconds dns_time{0};\n    size_t upload_size{0};\n    size_t download_size{0};\n    double upload_speed{0.0};\n    double download_speed{0.0};\n};\n```\n\n### Builder Pattern\n\n```cpp\nclass HttpClientBuilder {\npublic:\n    HttpClientBuilder\u0026 url(const std::string\u0026 url);\n    HttpClientBuilder\u0026 method(const std::string\u0026 method);\n    HttpClientBuilder\u0026 header(const std::string\u0026 name, const std::string\u0026 value);\n    HttpClientBuilder\u0026 body(const std::string\u0026 body);\n    HttpClientBuilder\u0026 jsonBody(const std::string\u0026 json);\n    HttpClientBuilder\u0026 formBody(const std::map\u003cstd::string, std::string\u003e\u0026 form);\n    HttpClientBuilder\u0026 timeout(int timeout_ms);\n    HttpClientBuilder\u0026 basicAuth(const std::string\u0026 username, const std::string\u0026 password);\n    HttpClientBuilder\u0026 bearerToken(const std::string\u0026 token);\n    HttpClientBuilder\u0026 apiKey(const std::string\u0026 key, const std::string\u0026 header = \"X-API-Key\");\n    HttpClientBuilder\u0026 userAgent(const std::string\u0026 user_agent);\n    HttpClientBuilder\u0026 enableMetrics(bool enable = true);\n    \n    HttpRequest build();\n    HttpResponse send();\n    std::future\u003cHttpResponse\u003e sendAsync();\n};\n```\n\n## Error Types\n\n```cpp\nenum class ErrorType {\n    None,\n    NetworkError,    // DNS resolution, connection failures\n    TimeoutError,    // Request timeout\n    SSLError,        // SSL/TLS certificate issues\n    InvalidUrl,      // Malformed URL\n    ResponseTooLarge, // Response exceeds size limit\n    Unknown          // Other errors\n};\n```\n\n## Thread Safety\n\n- **Different instances**: Fully thread-safe\n- **Same instance**: Requires external synchronization\n- **Connection pooling**: Thread-safe when enabled\n- **Async operations**: Safe to use concurrently\n\n## Performance Features\n\n- **Connection Pooling**: Reuses connections for better performance\n- **Compression**: Automatic gzip/deflate support\n- **Keep-Alive**: Persistent connections\n- **Async Operations**: Non-blocking requests\n- **Streaming**: Memory-efficient for large responses\n- **Metrics**: Built-in performance monitoring\n\n## Best Practices\n\n1. **Use Builder Pattern** for complex requests\n2. **Enable Connection Pooling** for high-throughput applications\n3. **Set Appropriate Timeouts** for your use case\n4. **Handle Errors Properly** using status code helpers\n5. **Use Streaming** for large responses\n6. **Monitor Performance** with built-in metrics\n7. **Configure Retry Logic** for resilient applications\n8. **Use Interceptors** for cross-cutting concerns\n\n## Examples in the Wild\n\nRun the comprehensive example to see all features in action:\n\n```bash\ncd build\n./blaze_example\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Add tests for new functionality\n5. Run the test suite: `./blaze_tests`\n6. Submit a pull request\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Acknowledgments\n\n- Built with [libcurl](https://curl.se/libcurl/) - The multiprotocol file transfer library\n- Testing with [Google Test](https://github.com/google/googletest) - Google's C++ test framework\n- Inspired by modern HTTP client libraries and C++17 design principles\n- Performance optimizations based on production use cases\n\n## Changelog\n\n### v2.0.0\n\n- Complete rewrite with enterprise-grade features\n- Builder pattern for fluent API\n- Enhanced authentication and SSL support\n- Connection pooling and performance optimizations\n- Comprehensive metrics and monitoring\n- Response streaming capabilities\n- Retry logic with exponential backoff\n- Request/response interceptors\n- Utility functions for common tasks\n- 42 comprehensive test cases\n\n### v1.0.0\n\n- Initial release with basic HTTP functionality","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmalwarebo%2Fblaze","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmalwarebo%2Fblaze","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmalwarebo%2Fblaze/lists"}