| 349 | } |
| 350 | |
| 351 | static SC::Result validateRequestUrl(SC::StringSpan url) |
| 352 | { |
| 353 | SC_TRY_MSG(url.sizeInBytes() > 0, "HttpClientRequest: URL is empty"); |
| 354 | |
| 355 | const SC::Span<const char> bytes = url.toCharSpan(); |
| 356 | SC_TRY_MSG(not hasUrlUnsafeBytes(url), "HttpClientRequest: URL contains whitespace or control bytes"); |
| 357 | |
| 358 | size_t schemeBytes = 0; |
| 359 | if (asciiStartsWithIgnoreCase(url, SC::StringSpan("http://"))) |
| 360 | { |
| 361 | schemeBytes = sizeof("http://") - 1; |
| 362 | } |
| 363 | else if (asciiStartsWithIgnoreCase(url, SC::StringSpan("https://"))) |
| 364 | { |
| 365 | schemeBytes = sizeof("https://") - 1; |
| 366 | } |
| 367 | else |
| 368 | { |
| 369 | return SC::Result::Error("HttpClientRequest: only http:// and https:// URLs are supported"); |
| 370 | } |
| 371 | |
| 372 | SC_TRY_MSG(bytes.sizeInBytes() > schemeBytes, "HttpClientRequest: URL host is empty"); |
| 373 | SC_TRY_MSG(bytes[schemeBytes] != '/' and bytes[schemeBytes] != '?' and bytes[schemeBytes] != '#', |
| 374 | "HttpClientRequest: URL host is empty"); |
| 375 | return SC::Result(true); |
| 376 | } |
| 377 | |
| 378 | static SC::Result validateRequestOptionsShape(const SC::HttpClientRequestOptions& options) |
| 379 | { |
no test coverage detected