{"id":13423620,"url":"https://github.com/yhirose/cpp-httplib","last_synced_at":"2026-03-15T06:58:21.966Z","repository":{"id":4759448,"uuid":"5909706","full_name":"yhirose/cpp-httplib","owner":"yhirose","description":"A C++ header-only HTTP/HTTPS server and client library","archived":false,"fork":false,"pushed_at":"2026-03-10T00:54:13.000Z","size":5121,"stargazers_count":16225,"open_issues_count":1,"forks_count":2647,"subscribers_count":192,"default_branch":"master","last_synced_at":"2026-03-10T08:33:52.186Z","etag":null,"topics":["cpp","cpp11","header-only","http","https"],"latest_commit_sha":null,"homepage":"https://yhirose.github.io/cpp-httplib/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yhirose.png","metadata":{"files":{"readme":"README-sse.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2012-09-22T02:38:32.000Z","updated_at":"2026-03-10T08:30:38.000Z","dependencies_parsed_at":"2026-01-31T05:14:51.001Z","dependency_job_id":null,"html_url":"https://github.com/yhirose/cpp-httplib","commit_stats":{"total_commits":1338,"total_committers":211,"mean_commits":6.341232227488152,"dds":"0.33482810164424515","last_synced_commit":"413994912d19b76262078fa54c4beb9de700b633"},"previous_names":[],"tags_count":152,"template":false,"template_full_name":null,"purl":"pkg:github/yhirose/cpp-httplib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yhirose%2Fcpp-httplib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yhirose%2Fcpp-httplib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yhirose%2Fcpp-httplib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yhirose%2Fcpp-httplib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yhirose","download_url":"https://codeload.github.com/yhirose/cpp-httplib/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yhirose%2Fcpp-httplib/sbom","scorecard":{"id":926192,"data":{"date":"2025-08-18","repo":{"name":"github.com/yhirose/cpp-httplib","commit":"fe7fe15d2ea9acf290dc27002f386649f750fa15"},"scorecard":{"version":"v5.2.1-41-g40576783","commit":"40576783fda6698350fcbbeaea760ff827433034"},"score":5.2,"checks":[{"name":"Maintained","score":10,"reason":"30 commit(s) and 23 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#packaging"}},{"name":"Code-Review","score":2,"reason":"Found 6/30 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#cii-best-practices"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/abidiff.yaml:1","Warn: no topLevel permission defined: .github/workflows/cifuzz.yaml:1","Warn: no topLevel permission defined: .github/workflows/test.yaml:1","Warn: no topLevel permission defined: .github/workflows/test_proxy.yaml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#token-permissions"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":10,"reason":"project is fuzzed","details":["Info: OSSFuzz integration found","Info: CppLibFuzzer integration found: test/fuzzing/server_fuzzer.cc:96","Info: CppLibFuzzer integration found: test/fuzzing/server_fuzzer.cc:96","Info: CppLibFuzzer integration found: test/fuzzing/standalone_fuzz_target_runner.cpp:15","Info: CppLibFuzzer integration found: test/fuzzing/standalone_fuzz_target_runner.cpp:18","Info: CppLibFuzzer integration found: test/fuzzing/standalone_fuzz_target_runner.cpp:29"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#branch-protection"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/abidiff.yaml:37: update your workflow using https://app.stepsecurity.io/secureworkflow/yhirose/cpp-httplib/abidiff.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/abidiff.yaml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/yhirose/cpp-httplib/abidiff.yaml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/cifuzz.yaml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/yhirose/cpp-httplib/cifuzz.yaml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/cifuzz.yaml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/yhirose/cpp-httplib/cifuzz.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/cifuzz.yaml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/yhirose/cpp-httplib/cifuzz.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yaml:58: update your workflow using https://app.stepsecurity.io/secureworkflow/yhirose/cpp-httplib/test.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yaml:80: update your workflow using https://app.stepsecurity.io/secureworkflow/yhirose/cpp-httplib/test.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yaml:103: update your workflow using https://app.stepsecurity.io/secureworkflow/yhirose/cpp-httplib/test.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yaml:138: update your workflow using https://app.stepsecurity.io/secureworkflow/yhirose/cpp-httplib/test.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yaml:140: update your workflow using https://app.stepsecurity.io/secureworkflow/yhirose/cpp-httplib/test.yaml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yaml:146: update your workflow using https://app.stepsecurity.io/secureworkflow/yhirose/cpp-httplib/test.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yaml:37: update your workflow using https://app.stepsecurity.io/secureworkflow/yhirose/cpp-httplib/test.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test_proxy.yaml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/yhirose/cpp-httplib/test_proxy.yaml/master?enable=pin","Warn: containerImage not pinned by hash: Dockerfile:1","Warn: containerImage not pinned by hash: example/Dockerfile.hello:1","Warn: containerImage not pinned by hash: example/Dockerfile.hello:9: pin your Docker image by updating alpine to alpine@sha256:4bcff63911fcb4448bd4fdacec207030997caf25e9bea4045fa6c8c44de311d1","Warn: containerImage not pinned by hash: test/proxy/Dockerfile:1: pin your Docker image by updating alpine:latest to alpine:latest@sha256:4bcff63911fcb4448bd4fdacec207030997caf25e9bea4045fa6c8c44de311d1","Info:   0 out of  10 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   3 third-party GitHubAction dependencies pinned","Info:   0 out of   4 containerImage dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 11 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-27T03:47:29.323Z","repository_id":4759448,"created_at":"2025-08-27T03:47:29.324Z","updated_at":"2025-08-27T03:47:29.324Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30537152,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-15T06:53:40.532Z","status":"ssl_error","status_checked_at":"2026-03-15T06:51:47.131Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["cpp","cpp11","header-only","http","https"],"created_at":"2024-07-31T00:00:39.058Z","updated_at":"2026-03-15T06:58:21.929Z","avatar_url":"https://github.com/yhirose.png","language":"C++","readme":"# SSEClient - Server-Sent Events Client\n\nA simple, EventSource-like SSE client for C++11.\n\n## Features\n\n- **Auto-reconnect**: Automatically reconnects on connection loss\n- **Last-Event-ID**: Sends last received ID on reconnect for resumption\n- **retry field**: Respects server's reconnect interval\n- **Event types**: Supports custom event types via `on_event()`\n- **Async support**: Run in background thread with `start_async()`\n- **C++11 compatible**: No C++14/17/20 features required\n\n## Quick Start\n\n```cpp\nhttplib::Client cli(\"http://localhost:8080\");\nhttplib::sse::SSEClient sse(cli, \"/events\");\n\nsse.on_message([](const httplib::sse::SSEMessage \u0026msg) {\n    std::cout \u003c\u003c \"Event: \" \u003c\u003c msg.event \u003c\u003c std::endl;\n    std::cout \u003c\u003c \"Data: \" \u003c\u003c msg.data \u003c\u003c std::endl;\n});\n\nsse.start();  // Blocking, with auto-reconnect\n```\n\n## API Reference\n\n### SSEMessage\n\n```cpp\nstruct SSEMessage {\n    std::string event;  // Event type (default: \"message\")\n    std::string data;   // Event payload\n    std::string id;     // Event ID\n};\n```\n\n### SSEClient\n\n#### Constructor\n\n```cpp\n// Basic\nSSEClient(Client \u0026client, const std::string \u0026path);\n\n// With custom headers\nSSEClient(Client \u0026client, const std::string \u0026path, const Headers \u0026headers);\n```\n\n#### Event Handlers\n\n```cpp\n// Called for all events (or events without a specific handler)\nsse.on_message([](const SSEMessage \u0026msg) { });\n\n// Called for specific event types\nsse.on_event(\"update\", [](const SSEMessage \u0026msg) { });\nsse.on_event(\"delete\", [](const SSEMessage \u0026msg) { });\n\n// Called when connection is established\nsse.on_open([]() { });\n\n// Called on connection errors\nsse.on_error([](httplib::Error err) { });\n```\n\n#### Configuration\n\n```cpp\n// Set reconnect interval (default: 3000ms)\nsse.set_reconnect_interval(5000);\n\n// Set max reconnect attempts (default: 0 = unlimited)\nsse.set_max_reconnect_attempts(10);\n```\n\n#### Control\n\n```cpp\n// Blocking start with auto-reconnect\nsse.start();\n\n// Non-blocking start (runs in background thread)\nsse.start_async();\n\n// Stop the client (thread-safe)\nsse.stop();\n```\n\n#### State\n\n```cpp\nbool connected = sse.is_connected();\nconst std::string \u0026id = sse.last_event_id();\n```\n\n## Examples\n\n### Basic Usage\n\n```cpp\nhttplib::Client cli(\"http://localhost:8080\");\nhttplib::sse::SSEClient sse(cli, \"/events\");\n\nsse.on_message([](const httplib::sse::SSEMessage \u0026msg) {\n    std::cout \u003c\u003c msg.data \u003c\u003c std::endl;\n});\n\nsse.start();\n```\n\n### With Custom Event Types\n\n```cpp\nhttplib::sse::SSEClient sse(cli, \"/events\");\n\nsse.on_event(\"notification\", [](const httplib::sse::SSEMessage \u0026msg) {\n    std::cout \u003c\u003c \"Notification: \" \u003c\u003c msg.data \u003c\u003c std::endl;\n});\n\nsse.on_event(\"update\", [](const httplib::sse::SSEMessage \u0026msg) {\n    std::cout \u003c\u003c \"Update: \" \u003c\u003c msg.data \u003c\u003c std::endl;\n});\n\nsse.start();\n```\n\n### Async with Stop\n\n```cpp\nhttplib::sse::SSEClient sse(cli, \"/events\");\n\nsse.on_message([](const httplib::sse::SSEMessage \u0026msg) {\n    std::cout \u003c\u003c msg.data \u003c\u003c std::endl;\n});\n\nsse.start_async();  // Returns immediately\n\n// ... do other work ...\n\nsse.stop();  // Stop when done\n```\n\n### With Custom Headers (e.g., Authentication)\n\n```cpp\nhttplib::Headers headers = {\n    {\"Authorization\", \"Bearer token123\"}\n};\n\nhttplib::sse::SSEClient sse(cli, \"/events\", headers);\nsse.start();\n```\n\n### Error Handling\n\n```cpp\nsse.on_error([](httplib::Error err) {\n    std::cerr \u003c\u003c \"Error: \" \u003c\u003c httplib::to_string(err) \u003c\u003c std::endl;\n});\n\nsse.set_reconnect_interval(1000);\nsse.set_max_reconnect_attempts(5);\n\nsse.start();\n```\n\n## SSE Protocol\n\nThe client parses SSE format according to the [W3C specification](https://html.spec.whatwg.org/multipage/server-sent-events.html):\n\n```\nevent: custom-type\nid: 123\ndata: {\"message\": \"hello\"}\n\ndata: simple message\n\n: this is a comment (ignored)\n```\n","funding_links":[],"categories":["C++","Networking","Communication Clients","Language-Specific Tools","Learning Roadmap","网络服务","内存分配","HTTP and the Web","Libraries","Libraries and Frameworks","C/C++生态圈Dev\u0026Ops工具与服务","Programming Languages","Rest protocol"],"sub_categories":["fake data","C/C++","Stage 4: Systems Programming (4–6 weeks)","网络服务_其他","网络","C++","HTTP and Networking"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyhirose%2Fcpp-httplib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyhirose%2Fcpp-httplib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyhirose%2Fcpp-httplib/lists"}