feat: add URL parser foundation - #6
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2c0d64ddcf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -0,0 +1,16 @@ | |||
| find_package(GTest CONFIG REQUIRED) | |||
There was a problem hiding this comment.
Restore a fallback before requiring GTest
On any clean build environment without a preinstalled GTest CMake config, configuration now stops at this line; this includes the checked .github/workflows/ci.yml path, which runs plain cmake -B build without activating the repository's vcpkg toolchain or installing GTest. The repository already has cmake/packages/google-test.cmake to fetch GTest when it is unavailable, so use that bootstrap or otherwise make tests optional instead of making a test-only dependency mandatory for every library configuration.
Useful? React with 👍 / 👎.
| target_compile_features(cpp_request_tests PRIVATE cxx_std_17) | ||
|
|
||
| include(GoogleTest) | ||
| gtest_discover_tests(cpp_request_tests) |
There was a problem hiding this comment.
Enable CTest before registering the URL tests
When GTest is available, this registration is still ineffective because no active CMake path calls enable_testing() or includes CTest; the only existing call is in the unused cmake/packages/google-test.cmake. As documented by cmake --help-command enable_testing, testing must be enabled from the source root, and configuring this tree with a GTest config followed by ctest -N reports Total Tests: 0, so these URL tests will never run through CTest.
Useful? React with 👍 / 👎.
| if (authority.front() == '[') { | ||
| const std::size_t closing = authority.find(']'); | ||
| if (closing == std::string_view::npos || closing == 1) { | ||
| return Error{ErrorCode::InvalidUrl}; | ||
| } | ||
|
|
||
| result.host_is_ipv6_literal_ = true; |
There was a problem hiding this comment.
Validate bracketed hosts before marking them as IPv6
For any nonempty bracket contents, the parser reports success and sets host_is_ipv6_literal_ without checking IPv6 syntax. For example, Url::parse("http://[example.com]/") and Url::parse("http://[:::]/") both succeed and are labeled IPv6 literals even though those are not valid IPv6 addresses, violating the parser's structured invalid-URL behavior; validate the bracketed address before accepting it and setting this metadata.
Useful? React with 👍 / 👎.
Summary
Starts the first v1 implementation slice by adding the foundational public error/result types and a tested HTTP URL parser.
Added
include/cpp_request/error.hppErrorCodetaxonomy from the v1 error-model docsErrorwith optional native diagnostic codeerror_message()include/cpp_request/result.hppResult<T>backed bystd::variant<T, Error>[[nodiscard]],has_value(), explicitoperator bool(),value(), anderror()include/cpp_request/url.hppsrc/url.cpphttp://parsing/pathtests/url_test.cppBuild changes
tests/Scope
This PR intentionally does not implement DNS, sockets, HTTP serialization, response parsing, or
Clientyet. It establishes the value/error and URL foundation those layers will build on.