blob: ceb1229745a5a1f3b0ef84d8d1461649a83cac0b [file] [log] [blame]
Paul Stewart95133562012-01-18 18:36:57 -08001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Ben Chanc45688b2014-07-02 23:50:45 -07005#ifndef SHILL_HTTP_URL_H_
6#define SHILL_HTTP_URL_H_
Paul Stewart95133562012-01-18 18:36:57 -08007
Ben Chancc67c522014-09-03 07:19:18 -07008#include <base/macros.h>
Paul Stewart95133562012-01-18 18:36:57 -08009
10#include <string>
11
12namespace shill {
13
14// Simple URL parsing class.
15class HTTPURL {
16 public:
17 enum Protocol {
18 kProtocolUnknown,
19 kProtocolHTTP,
20 kProtocolHTTPS
21 };
22
23 static const int kDefaultHTTPPort;
24 static const int kDefaultHTTPSPort;
25
26 HTTPURL();
27 virtual ~HTTPURL();
28
29 // Parse a URL from |url_string|.
Paul Stewart8ae18742015-06-16 13:13:10 -070030 bool ParseFromString(const std::string& url_string);
Paul Stewart95133562012-01-18 18:36:57 -080031
Paul Stewart8ae18742015-06-16 13:13:10 -070032 const std::string& host() const { return host_; }
33 const std::string& path() const { return path_; }
Paul Stewart95133562012-01-18 18:36:57 -080034 int port() const { return port_; }
35 Protocol protocol() const { return protocol_; }
36
37 private:
38 static const char kDelimiters[];
39 static const char kPortSeparator;
40 static const char kPrefixHTTP[];
41 static const char kPrefixHTTPS[];
42
43 std::string host_;
44 std::string path_;
45 int port_;
46 Protocol protocol_;
47
48 DISALLOW_COPY_AND_ASSIGN(HTTPURL);
49};
50
51} // namespace shill
52
Ben Chanc45688b2014-07-02 23:50:45 -070053#endif // SHILL_HTTP_URL_H_