• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Url.h

Go to the documentation of this file.
00001 /**
00002   Licensed to the Apache Software Foundation (ASF) under one
00003   or more contributor license agreements.  See the NOTICE file
00004   distributed with this work for additional information
00005   regarding copyright ownership.  The ASF licenses this file
00006   to you under the Apache License, Version 2.0 (the
00007   "License"); you may not use this file except in compliance
00008   with the License.  You may obtain a copy of the License at
00009 
00010       http://www.apache.org/licenses/LICENSE-2.0
00011 
00012   Unless required by applicable law or agreed to in writing, software
00013   distributed under the License is distributed on an "AS IS" BASIS,
00014   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015   See the License for the specific language governing permissions and
00016   limitations under the License.
00017  */
00018 /**
00019  * @file Url.h
00020  */
00021 
00022 #pragma once
00023 #ifndef ATSCPPAPI_URL_H_
00024 #define ATSCPPAPI_URL_H_
00025 
00026 #include <string>
00027 #include <stdint.h>
00028 #include <atscppapi/noncopyable.h>
00029 
00030 namespace atscppapi {
00031 
00032 struct UrlState;
00033 
00034 /**
00035  * @brief This class contains all properties of a Url.
00036  *
00037  * You can use a Url object to get and set any property of a url.
00038  *
00039  * @warning Url objects should never be constructed by the user.
00040  * If a user needs to create an unbound Url then they should create a Request
00041  * object using Request::Request(string) which will construct a Url object for them
00042  * and it can be retrieved via Request::getUrl(). A full example of this
00043  * is available in examples/detachedrequest/.
00044  */
00045 class Url: noncopyable {
00046 public:
00047   /**
00048    * @warning Url objects should never be constructed by the user.
00049    * If a user needs to create an unbound Url then they should create a Request
00050    * object using Request::Request(string) which will construct a Url object for them
00051    * and it can be retrieved via Request::getUrl(). A full example of this
00052    * is available in examples/detachedrequest/.
00053    *
00054    * @private
00055    */
00056   Url();
00057 
00058   /**
00059    * @warning Url objects should never be constructed by the user.
00060    * If a user needs to create an unbound Url then they should create a Request
00061    * object using Request::Request(string) which will construct a Url object for them
00062    * and it can be retrieved via Request::getUrl(). A full example of this
00063    * is available in examples/detachedrequest/.
00064    *
00065    * @private
00066    */
00067   Url(void *hdr_buf, void *url_loc);
00068   ~Url();
00069 
00070   /**
00071    * @return The full url as a string, such a url might be http://trafficserver.apache.org/search?q=blah
00072    */
00073   std::string getUrlString() const;
00074 
00075   /**
00076    * @return The path only portion of the url, such as /search
00077    */
00078   std::string getPath() const;
00079 
00080   /**
00081    * @return The query only portion of the url, which might be q=blah
00082    */
00083   std::string getQuery() const;
00084 
00085   /**
00086    * @return The scheme of the url, this will be either http or https.
00087    */
00088   std::string getScheme() const;
00089 
00090   /**
00091    * @return The host only of the url, this might be www.google.com
00092    */
00093   std::string getHost() const;
00094 
00095   /**
00096    * @return The port only portion of the url, this will likely be 80 or 443.
00097    */
00098   uint16_t getPort() const;
00099 
00100   /**
00101    * Set the path of the url.
00102    * @param path the path portion of the url to set, this might be something like /foo/bar
00103    */
00104   void setPath(const std::string &);
00105 
00106   /**
00107    * Set the query param of the url.
00108    * @param query the query portion of the url, this might be something like foo=bar&blah=baz.
00109    */
00110   void setQuery(const std::string &);
00111 
00112   /**
00113    * Set the scheme of the url
00114    * @param scheme this might be either http or https.
00115    */
00116   void setScheme(const std::string &);
00117 
00118   /**
00119    * Set the host of the url
00120    * @param host this might be something such as www.linkedin.com or www.apache.org
00121    */
00122   void setHost(const std::string &);
00123 
00124   /**
00125    * Set the port portion of the url.
00126    * @param port this is a uint16_t which represents the port (in host order, there is no need to conver to network order). You
00127    * might use a value such as 80 or 8080.
00128    */
00129   void setPort(const uint16_t);
00130 
00131   /**
00132    * This method allows you to reset the url, this will force the Url to fully re-read all cached values.
00133    * If this method is used on a Detached Requests' Url object it will completely destroy the values.
00134    *
00135    * \note This method should rarely be used.
00136    */
00137   void reset();
00138 private:
00139   bool isInitialized() const;
00140   void init(void *hdr_buf, void *url_loc);
00141   UrlState *state_;
00142   friend class Request;
00143   friend class ClientRequest;
00144   friend class RemapPlugin;
00145 };
00146 
00147 }
00148 
00149 #endif /* ATSCPPAPI_URL_H_ */

Generated by  doxygen 1.7.1