1.. Licensed to the Apache Software Foundation (ASF) under one 2 or more contributor license agreements. See the NOTICE file 3 distributed with this work for additional information 4 regarding copyright ownership. The ASF licenses this file 5 to you under the Apache License, Version 2.0 (the 6 "License"); you may not use this file except in compliance 7 with the License. You may obtain a copy of the License at 8 9 http://www.apache.org/licenses/LICENSE-2.0 10 11 Unless required by applicable law or agreed to in writing, 12 software distributed under the License is distributed on an 13 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 KIND, either express or implied. See the License for the 15 specific language governing permissions and limitations 16 under the License. 17 18.. include:: ../../../common.defs 19 20.. default-domain:: c 21 22TSUrlHostGet 23************ 24 25Traffic Server URL component retrieval API. 26 27Synopsis 28======== 29 30.. code-block:: cpp 31 32 #include <ts/ts.h> 33 34.. function:: const char * TSUrlHostGet(TSMBuffer bufp, TSMLoc offset, int * length) 35.. function:: const char * TSUrlSchemeGet(TSMBuffer bufp, TSMLoc offset, int * length) 36.. function:: const char * TSUrlRawSchemeGet(TSMBuffer bufp, TSMLoc offset, int * length) 37.. function:: const char * TSUrlUserGet(TSMBuffer bufp, TSMLoc offset, int * length) 38.. function:: const char * TSUrlPasswordGet(TSMBuffer bufp, TSMLoc offset, int* length) 39.. function:: int TSUrlPortGet(TSMBuffer bufp, TSMLoc offset) 40.. function:: int TSUrlRawPortGet(TSMBuffer bufp, TSMLoc offset) 41.. function:: const char * TSUrlPathGet(TSMBuffer bufp, TSMLoc offset, int * length) 42.. function:: const char * TSUrlHttpQueryGet(TSMBuffer bufp, TSMLoc offset, int * length) 43.. function:: const char * TSUrlHttpParamsGet(TSMBuffer bufp, TSMLoc offset, int * length) 44.. function:: const char * TSUrlHttpFragmentGet(TSMBuffer bufp, TSMLoc offset, int * length) 45 46Description 47=========== 48 49The URL data structure is a parsed version of a standard internet URL. The 50Traffic Server URL API provides access to URL data stored in marshal 51buffers. The URL functions can create, copy, retrieve or delete entire URLs, 52and retrieve or modify parts of URLs, such as their host, port or scheme 53information. 54 55:func:`TSUrlSchemeGet`, :func:`TSUrlRawSchemeGet`, :func:`TSUrlUserGet`, :func:`TSUrlPasswordGet`, 56:func:`TSUrlHostGet`, :func:`TSUrlPathGet`, :func:`TSUrlHttpParamsGet`, :func:`TSUrlHttpQueryGet` 57and :func:`TSUrlHttpFragmentGet` each retrieve an internal pointer to the 58specified portion of the URL from the marshall buffer :arg:`bufp`. The length 59of the returned string is placed in :arg:`length` and a pointer to the URL 60portion is returned. 61 62If a request URL does not have a explicit scheme, :func:`TSUrlRawSchemeGet` will return null and 63set :arg:`length` to zero. :func:`TSUrlSchemeGet`, will return the scheme corresponding to the 64URL type (HTTP or HTTPS) if there is no explicit scheme. 65 66:func:`TSUrlPortGet` retrieves the port number portion of the URL located at 67:arg:`offset` within the marshal buffer :arg:`bufp`. If there is no explicit 68port number in the URL, a canonicalized valued is returned based on the URL 69scheme. 70 71:func:`TSUrlRawPortGet` also retrieves the port number portion of the URL located at 72:arg:`offset` within the marshal buffer :arg:`bufp`. If there is no explicit 73port number in the URL, zero is returned. 74 75Return Values 76============= 77 78All APIs except :func:`TSUrlPortGet` and :func:`TSUrlRawPortGet` return a string, which is 79not guaranteed to be NULL terminated. You must therefore always use the :arg:`length` value 80to determine the actual length of the returned string. 81 82:func:`TSUrlPortGet` simply returns the port number as an integer, possibly 83canonicalized with :literal:`80` for HTTP and :literal:`443` for HTTPS schemes. If 84there is neither port nor scheme information available in the URL, :literal:`0` 85is returned. :func:`TSUrlRawPortGet`, by contrast, returns 0 in all cases where the 86port is not explicitly present in the URL. 87 88See Also 89======== 90 91:manpage:`TSAPI(3ts)`, 92:manpage:`TSUrlCreate(3ts)`, 93:manpage:`TSHttpHdrUrlGet(3ts)`, 94:manpage:`TSUrlHostSet(3ts)`, 95:manpage:`TSUrlStringGet(3ts)`, 96:manpage:`TSUrlPercentEncode(3ts)` 97