mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:47:35 +00:00
AK: Add a basic URL class to help us handle URL's
We're gonna need these as we start to write more networking programs.
This commit is contained in:
parent
aaccf6ee4e
commit
ed43770b2f
5 changed files with 223 additions and 1 deletions
38
AK/URL.h
Normal file
38
AK/URL.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/AKString.h>
|
||||
#include <AK/StringView.h>
|
||||
|
||||
namespace AK {
|
||||
|
||||
class URL {
|
||||
public:
|
||||
URL() {}
|
||||
URL(const StringView&);
|
||||
|
||||
bool is_valid() const { return m_valid; }
|
||||
String protocol() const { return m_protocol; }
|
||||
String host() const { return m_host; }
|
||||
String path() const { return m_path; }
|
||||
u16 port() const { return m_port; }
|
||||
|
||||
String to_string() const;
|
||||
|
||||
private:
|
||||
bool parse(const StringView&);
|
||||
|
||||
bool m_valid { false };
|
||||
u16 m_port { 80 };
|
||||
String m_protocol;
|
||||
String m_host;
|
||||
String m_path;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
using AK::URL;
|
||||
|
||||
inline const LogStream& operator<<(const LogStream& stream, const URL& value)
|
||||
{
|
||||
return stream << value.to_string();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue