folly::Unit::Drop.
[folly.git] / folly / Uri.h
index 581307d928d8315e3ab417a38fa1345159ef048c..739fc38f8e53f7e5c54224889e0572e905f0ea9c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2015 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -76,7 +76,10 @@ class Uri {
   std::string str() const { return toString<std::string>(); }
   fbstring fbstr() const { return toString<fbstring>(); }
 
-  void setPort(uint16_t port) {port_ = port;}
+  void setPort(uint16_t port) {
+    hasAuthority_ = true;
+    port_ = port;
+  }
 
   /**
    * Get query parameters as key-value pairs.
@@ -90,19 +93,22 @@ class Uri {
    * one equal signs, we don't know which one is the delimiter for key and
    * value.
    *
+   * Note, this method is not thread safe, it might update internal state, but
+   * only the first call to this method update the state. After the first call
+   * is finished, subsequent calls to this method are thread safe.
+   *
    * @return  query parameter key-value pairs in a vector, each element is a
    *          pair of which the first element is parameter name and the second
    *          one is parameter value
    */
-  const std::vector<std::pair<fbstring, fbstring>>& getQueryParams() const {
-    return queryParams_;
-  };
+  const std::vector<std::pair<fbstring, fbstring>>& getQueryParams();
 
  private:
   fbstring scheme_;
   fbstring username_;
   fbstring password_;
   fbstring host_;
+  bool hasAuthority_;
   uint16_t port_;
   fbstring path_;
   fbstring query_;