A URL object.
| 186 | |
| 187 | /// A URL object. |
| 188 | class URL : public HeapObject |
| 189 | { |
| 190 | friend class HttpHeader; |
| 191 | |
| 192 | using self_type = URL; ///< Self reference type. |
| 193 | using super_type = HeapObject; ///< Parent type. |
| 194 | public: |
| 195 | URL() = default; |
| 196 | |
| 197 | /// Construct from TS data. |
| 198 | URL(TSMBuffer buff, TSMLoc loc); |
| 199 | |
| 200 | /** Write the full URL to @a w. |
| 201 | * |
| 202 | * @param w Destination buffer. |
| 203 | * @return @a w |
| 204 | */ |
| 205 | swoc::BufferWriter &write_full(swoc::BufferWriter &w) const; |
| 206 | |
| 207 | /** Get the network location |
| 208 | * |
| 209 | * @return A tuple of [ host, port ]. |
| 210 | */ |
| 211 | std::tuple<swoc::TextView, in_port_t> loc() const; |
| 212 | |
| 213 | swoc::TextView host() const; ///< View of the URL host. |
| 214 | |
| 215 | /** Get the port in the URL. |
| 216 | * |
| 217 | * @return The port. |
| 218 | * |
| 219 | * @note If the port is not explicitly set, it is computed based on the scheme. |
| 220 | */ |
| 221 | in_port_t port() const; ///< Port. |
| 222 | swoc::TextView scheme() const; ///< View of the URL scheme. |
| 223 | swoc::TextView path() const; ///< View of the URL path. |
| 224 | swoc::TextView query() const; ///< View of the query. |
| 225 | swoc::TextView fragment() const; ///< View of the fragment. |
| 226 | |
| 227 | /** Set the scheme for the URL. |
| 228 | * |
| 229 | * @param scheme Scheme as text. |
| 230 | * @return @a this |
| 231 | */ |
| 232 | self_type &scheme_set(swoc::TextView const &scheme); |
| 233 | |
| 234 | /** Set the host in the URL. |
| 235 | * |
| 236 | * @param host Host. |
| 237 | * @return @a this. |
| 238 | */ |
| 239 | self_type &host_set(swoc::TextView const &host); |
| 240 | |
| 241 | static bool is_port_canonical(swoc::TextView const &scheme, in_port_t port); |
| 242 | |
| 243 | bool |
| 244 | is_port_canonical() const |
| 245 | { |
nothing calls this directly
no test coverage detected