Codemod: use #include angle brackets in folly and thrift
[folly.git] / folly / Uri.h
index 8885bb9f40d235afd0f47137f1c596ebc78cdd6f..e7b38615801261799f2bebeb2a0564a850c640f5 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.
@@ -17,7 +17,7 @@
 #ifndef FOLLY_URI_H_
 #define FOLLY_URI_H_
 
-#include "folly/String.h"
+#include <folly/String.h>
 
 namespace folly {
 
@@ -47,24 +47,42 @@ 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_; }
-  uint32_t port() const { return port_; }
+  /**
+   * 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_; }
   const fbstring& fragment() const { return fragment_; }
 
+  fbstring authority() const;
+
   template <class String>
   String toString() const;
 
   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_;
   fbstring password_;
   fbstring host_;
-  uint32_t port_;
+  uint16_t port_;
   fbstring path_;
   fbstring query_;
   fbstring fragment_;
@@ -72,6 +90,6 @@ class Uri {
 
 }  // namespace folly
 
-#include "folly/Uri-inl.h"
+#include <folly/Uri-inl.h>
 
 #endif /* FOLLY_URI_H_ */