You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by am...@apache.org on 2014/09/28 21:32:08 UTC
git commit: TS-3101: Add TSHttpHdrHostGet
Repository: trafficserver
Updated Branches:
refs/heads/master a70d18875 -> b16c20879
TS-3101: Add TSHttpHdrHostGet
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/b16c2087
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/b16c2087
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/b16c2087
Branch: refs/heads/master
Commit: b16c20879c7809fdbff55ac1ee76c1bf7afd29de
Parents: a70d188
Author: Alan M. Carroll <am...@network-geographics.com>
Authored: Sun Sep 28 14:31:52 2014 -0500
Committer: Alan M. Carroll <am...@network-geographics.com>
Committed: Sun Sep 28 14:31:52 2014 -0500
----------------------------------------------------------------------
doc/reference/api/TSHttpHdrHostGet.en.rst | 36 ++++++++++++++++++++++++++
proxy/InkAPI.cc | 13 ++++++++++
proxy/api/ts/ts.h | 1 +
3 files changed, 50 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b16c2087/doc/reference/api/TSHttpHdrHostGet.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/api/TSHttpHdrHostGet.en.rst b/doc/reference/api/TSHttpHdrHostGet.en.rst
new file mode 100644
index 0000000..0498271
--- /dev/null
+++ b/doc/reference/api/TSHttpHdrHostGet.en.rst
@@ -0,0 +1,36 @@
+.. 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.
+
+
+TSHttpHdrHostGet
+==================
+
+Synopsis
+--------
+
+`#include <ts/ts.h>`
+
+.. c:function:: const char* TSHttpHdrHostGet(TSMBuffer bufp, TSMLoc offset, int *length)
+
+
+Description
+-----------
+
+Get the host for the request. :arg:`bufp` and :arg:`offset` must reference an HTTP request header. A pointer to the host
+is returned and the length is stored in the ``int`` pointed at by :arg:`length`. Note the returned text may not
+be null terminated. The URL in the request is checked first then the ``HOST`` header field.
+
+..note: This is much faster than calling :c:func:`TSHttpEffectiveUrlStringGet` and extracting the host from the result.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b16c2087/proxy/InkAPI.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index f7c8927..4054d34 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -3767,6 +3767,19 @@ TSHttpHdrMethodSet(TSMBuffer bufp, TSMLoc obj, const char *value, int length)
return TS_SUCCESS;
}
+const char *
+TSHttpHdrHostGet(TSMBuffer bufp, TSMLoc obj, int *length)
+{
+ sdk_assert(sdk_sanity_check_mbuffer(bufp) == TS_SUCCESS);
+ sdk_assert(sdk_sanity_check_http_hdr_handle(obj) == TS_SUCCESS);
+ sdk_assert(sdk_sanity_check_null_ptr((void*)length) == TS_SUCCESS);
+
+ HTTPHdr h;
+
+ SET_HTTP_HDR(h, bufp, obj);
+ return h.host_get(length);
+}
+
TSReturnCode
TSHttpHdrUrlGet(TSMBuffer bufp, TSMLoc obj, TSMLoc *locp)
{
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b16c2087/proxy/api/ts/ts.h
----------------------------------------------------------------------
diff --git a/proxy/api/ts/ts.h b/proxy/api/ts/ts.h
index 50b7c12..3a6eed6 100644
--- a/proxy/api/ts/ts.h
+++ b/proxy/api/ts/ts.h
@@ -1109,6 +1109,7 @@ extern "C"
tsapi const char* TSHttpHdrMethodGet(TSMBuffer bufp, TSMLoc offset, int* length);
tsapi TSReturnCode TSHttpHdrMethodSet(TSMBuffer bufp, TSMLoc offset, const char* value, int length);
+ tsapi const char* TSHttpHdrHostGet(TSMBuffer bufp, TSMLoc offset, int* length);
tsapi TSReturnCode TSHttpHdrUrlGet(TSMBuffer bufp, TSMLoc offset, TSMLoc* locp);
tsapi TSReturnCode TSHttpHdrUrlSet(TSMBuffer bufp, TSMLoc offset, TSMLoc url);