{"id":25164467,"url":"https://github.com/vizonex/llhttpplus","last_synced_at":"2025-04-03T15:47:48.577Z","repository":{"id":235018242,"uuid":"789919395","full_name":"Vizonex/llhttpplus","owner":"Vizonex","description":"A C++ wrapper around llhttp for writing custom http parser tools in an object oriented way.","archived":false,"fork":false,"pushed_at":"2024-04-21T22:42:27.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-09T04:41:05.091Z","etag":null,"topics":["cpp","http-parser","llhttp","oop"],"latest_commit_sha":null,"homepage":"","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/Vizonex.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}},"created_at":"2024-04-21T22:41:25.000Z","updated_at":"2024-04-21T22:43:38.000Z","dependencies_parsed_at":"2024-04-22T02:25:05.278Z","dependency_job_id":"4095f4ca-5397-4771-b76d-22b4930525de","html_url":"https://github.com/Vizonex/llhttpplus","commit_stats":null,"previous_names":["vizonex/llhttpplus"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vizonex%2Fllhttpplus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vizonex%2Fllhttpplus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vizonex%2Fllhttpplus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vizonex%2Fllhttpplus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Vizonex","download_url":"https://codeload.github.com/Vizonex/llhttpplus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247033104,"owners_count":20872521,"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":["cpp","http-parser","llhttp","oop"],"created_at":"2025-02-09T04:32:03.623Z","updated_at":"2025-04-03T15:47:48.555Z","avatar_url":"https://github.com/Vizonex.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# llhttpplus\r\n\r\nA C++ Wrapper around [llhttp](https://llhttp.org) to make client and server protocols easier to handle...\r\nThis library has very minimal C++ code making it a good choice for developers who \r\nare looking to write an http requests library.\r\n\r\n\r\n```CPP\r\n\r\n#include \"llhttpplus.hpp\"\r\n#include \u003cunordered_map\u003e\r\n#include \u003cstdio.h\u003e\r\n\r\n\r\n/* NOTE: llhttp::string can be either std::string or std::string_view depending on your C++ version \r\n * This is why llhttp::string is used instead of std::string or std::string_view. At least later versions \r\n * of C++ have a performance increase because of std::string_view */\r\n\r\n\r\nclass ClientParser : public llhttp::Parser {\r\npublic: \r\n\r\n    /* There's also a built-in static constant expression known as SUCCESS = 0 AND FAIL = -1 */\r\n\r\n    /* Using these enums such as staus is entirely optional as the llhttp C library has it's own */\r\n    llhttp::Status status;\r\n    std::string header_name;\r\n    std::string header_value;\r\n    std::string body;\r\n\r\n    std::unordered_map\u003cstd::string, std::string\u003eheaders;\r\n\r\n\r\n    int on_status_complete(){\r\n        status = static_cast\u003cllhttp::Status\u003e(_handle.status_code);\r\n        switch(status){\r\n            case llhttp::Status::TOO_MANY_REQUESTS: {\r\n                printf(\"[FAILED] Sever kicked you off for sending out Too Many Requests :(\\n\");\r\n                return FAIL;\r\n            }\r\n            case llhttp::Status::OK: {\r\n                printf(\"[SUCCESS] The Server Approved of your Request :)\\n\")\r\n                return SUCCESS;\r\n            }\r\n    \r\n            /* .... */\r\n \r\n            default: {\r\n                return SUCCESS;\r\n            }\r\n        }\r\n    }\r\n\r\n    int on_header_field(llhttp::string str){\r\n        header_name += str;\r\n        return SUCCESS;\r\n    };\r\n    \r\n    int on_header_value(llhttp::string str){\r\n        header_value += str;\r\n        return SUCCESS;\r\n    };\r\n\r\n    int on_header_value_complete(){\r\n        headers.insert(header_name, header_value);\r\n        header_name.clear();\r\n        header_value.clear();\r\n        return SUCCESS;\r\n    }\r\n\r\n    int on_body(llhttp::string str){\r\n        body += str;\r\n        return SUCCESS;\r\n    }\r\n\r\n    ClientParser(){\r\n\r\n        /* The way I was able to get around settings class \r\n         * callbacks was to use flags for setting \r\n         * the parser up , Alternatively you could leave the \r\n         * setup handling to the other developers if your \r\n         * making an http library of your own with this \r\n         * library, Alternatively you can pass along \r\n         * \"::ALL\" for both DataCallbackSettings and \r\n         * CallbackSettings */\r\n\r\n        setup(\r\n            llhttp::CallbackSettings::Header_value_complete |  llhttp::CallbackSettings::Status_complete, \r\n            llhttp::DataCallbackSettings::Header_field | llhttp::DataCallbackSettings::Header_value,\r\n            llhttp::ParserType::RESPONSE \r\n        );\r\n    }\r\n};\r\n\r\n\r\nint parse_response(ClientParser* myClient, const char* response, size_t response_size){\r\n    /* std::string or std::string_view will also work... */\r\n    return static_cast\u003cint\u003e(myClient-\u003eexecute(response, response_size));\r\n}\r\n\r\n```\r\n\r\n\r\n\r\n## TODOS\r\n\r\n- CMAKELISTS.TXT\r\n- Tutorial\r\n- making sure llhttp compiles with this library \r\n- Testing this library\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvizonex%2Fllhttpplus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvizonex%2Fllhttpplus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvizonex%2Fllhttpplus/lists"}