Sane C++ Libraries
C++ Platform Abstraction Libraries
HttpURLParser.h
1// Copyright (c) Stefano Cristiano
2// SPDX-License-Identifier: MIT
3#pragma once
4#include "../Foundation/Result.h"
5#include "../Strings/StringView.h"
6
7namespace SC
8{
9struct SC_COMPILER_EXPORT HttpURLParser;
10} // namespace SC
11
14
17{
28
32 [[nodiscard]] Result parse(StringView url);
33
34 private:
35 [[nodiscard]] Result parsePath();
36 [[nodiscard]] Result parseHost();
37 [[nodiscard]] Result validateProtocol();
38 [[nodiscard]] Result validatePath();
39 [[nodiscard]] Result validateHost();
40 [[nodiscard]] Result parseUserPassword(StringView userPassword);
41};
42
#define SC_COMPILER_EXPORT
Macro for symbol visibility in non-MSVC compilers.
Definition: Compiler.h:78
unsigned short uint16_t
Platform independent (2) bytes unsigned int.
Definition: PrimitiveTypes.h:37
Parse an URL splitting it into its base components.
Definition: HttpURLParser.h:17
StringView hostname
Returns site.com (from http://user:pass@site.com:80/pa/th?q=val#hash)
Definition: HttpURLParser.h:21
StringView host
Returns site.com:80 (from http://user:pass@site.com:80/pa/th?q=val#hash)
Definition: HttpURLParser.h:23
StringView path
Returns /pa/th?q=val (from http://user:pass@site.com:80/pa/th?q=val#hash)
Definition: HttpURLParser.h:25
StringView protocol
Returns http (from http://user:pass@site.com:80/pa/th?q=val#hash)
Definition: HttpURLParser.h:18
StringView search
Returns ?q=val (from http://user:pass@site.com:80/pa/th?q=val#hash)
Definition: HttpURLParser.h:26
uint16_t port
Returns 80 (from http://user:pass@site.com:80/pa/th?q=val#hash)
Definition: HttpURLParser.h:22
StringView password
Returns pass (from http://user:pass@site.com:80/pa/th?q=val#hash)
Definition: HttpURLParser.h:20
StringView hash
Returns #hash (from http://user:pass@site.com:80/pa/th?q=val#hash)
Definition: HttpURLParser.h:27
StringView pathname
Returns /pa/th (from http://user:pass@site.com:80/pa/th?q=val#hash)
Definition: HttpURLParser.h:24
Result parse(StringView url)
Parse StringView representing an URL.
StringView username
Returns user (from http://user:pass@site.com:80/pa/th?q=val#hash)
Definition: HttpURLParser.h:19
An ascii string used as boolean result. SC_TRY macro forwards errors to caller.
Definition: Result.h:11
Non-owning view over a range of characters with UTF Encoding.
Definition: StringView.h:47