Small readability improvements
[folly.git] / folly / Uri.h
index b036058d6cf102a9a3f92e90148c012bf83710ae..5e7653092f4c716c1a23be166d80bc16e9397844 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2013 Facebook, Inc.
+ * Copyright 2014 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -47,7 +47,21 @@ class Uri {
   const fbstring& scheme() const { return scheme_; }
   const fbstring& username() const { return username_; }
   const fbstring& password() const { return password_; }
+  /**
+   * Get host part of URI. If host is an IPv6 address, square brackets will be
+   * returned, for example: "[::1]".
+   */
   const fbstring& host() const { return host_; }
+  /**
+   * Get host part of URI. If host is an IPv6 address, square brackets will not
+   * be returned, for exmaple "::1"; otherwise it returns the same thing as
+   * host().
+   *
+   * hostname() is what one needs to call if passing the host to any other tool
+   * or API that connects to that host/port; e.g. getaddrinfo() only understands
+   * IPv6 host without square brackets
+   */
+  fbstring hostname() const;
   uint16_t port() const { return port_; }
   const fbstring& path() const { return path_; }
   const fbstring& query() const { return query_; }
@@ -61,6 +75,8 @@ class Uri {
   std::string str() const { return toString<std::string>(); }
   fbstring fbstr() const { return toString<fbstring>(); }
 
+  void setPort(uint16_t port) {port_ = port;}
+
  private:
   fbstring scheme_;
   fbstring username_;