1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
/**
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* @file Url.h
*/
#pragma once
#include <string>
#include <cstdint>
#include "tscpp/api/noncopyable.h"
namespace atscppapi
{
struct UrlState;
/**
* @brief This class contains all properties of a Url.
*
* You can use a Url object to get and set any property of a url.
*
* @warning Url objects should never be constructed by the user.
* If a user needs to create an unbound Url then they should create a Request
* object using Request::Request(string) which will construct a Url object for them
* and it can be retrieved via Request::getUrl().
*/
class Url : noncopyable
{
public:
/**
* @warning Url objects should never be constructed by the user.
* If a user needs to create an unbound Url then they should create a Request
* object using Request::Request(string) which will construct a Url object for them
* and it can be retrieved via Request::getUrl().
*
* @private
*/
Url();
/**
* @warning Url objects should never be constructed by the user.
* If a user needs to create an unbound Url then they should create a Request
* object using Request::Request(string) which will construct a Url object for them
* and it can be retrieved via Request::getUrl().
*
* @private
*/
Url(void *hdr_buf, void *url_loc);
~Url();
/**
* @return The full url as a string, such a url might be http://trafficserver.apache.org/search?q=blah
*/
std::string getUrlString() const;
/**
* @return The path only portion of the url, such as /search
*/
std::string getPath() const;
/**
* @return The query only portion of the url, which might be q=blah
*/
std::string getQuery() const;
/**
* @return The scheme of the url, this will be either http or https.
*/
std::string getScheme() const;
/**
* @return The host only of the url, this might be www.google.com
*/
std::string getHost() const;
/**
* @return The port only portion of the url, this will likely be 80 or 443.
*/
uint16_t getPort() const;
/**
* Set the path of the url.
* @param path the path portion of the url to set, this might be something like /foo/bar
*/
void setPath(const std::string &);
/**
* Set the query param of the url.
* @param query the query portion of the url, this might be something like foo=bar&blah=baz.
*/
void setQuery(const std::string &);
/**
* Set the scheme of the url
* @param scheme this might be either http or https.
*/
void setScheme(const std::string &);
/**
* Set the host of the url
* @param host this might be something such as www.linkedin.com or www.apache.org
*/
void setHost(const std::string &);
/**
* Set the port portion of the url.
* @param port this is a uint16_t which represents the port (in host order, there is no need to convert to network order). You
* might use a value such as 80 or 8080.
*/
void setPort(const uint16_t);
private:
bool isInitialized() const;
void init(void *hdr_buf, void *url_loc);
UrlState *state_;
friend class Request;
friend class ClientRequest;
friend class RemapPlugin;
};
} // namespace atscppapi
|