blob: b98cb9ee07a18e051a26ea01185ba0a6d114ea77 [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
5#ifndef SHILL_HTTP_URL_
6#define SHILL_HTTP_URL_
7
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
53#endif // SHILL_HTTP_URL_