blob: 6398f1839ad502c116c8a26563e181345a47ded7 [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
8#include <base/basictypes.h>
9
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|.
30 bool ParseFromString(const std::string &url_string);
31
32 const std::string &host() const { return host_; }
33 const std::string &path() const { return path_; }
34 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_