trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zw...@apache.org
Subject [1/3] git commit: TS-2360 Fix usage of TSMimeHdrFieldValueStringGet() in some plugins.
Date Tue, 19 Nov 2013 05:14:36 GMT
Updated Branches:
  refs/heads/master 4626716fd -> b187978b8


TS-2360 Fix usage of TSMimeHdrFieldValueStringGet() in some plugins.

This also adds Sphinx docs for the TSMimeHdrFieldValueStringGet() and
family of APIs. Finally, it also adds a regression test for the -1
IDX argument.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/7878e058
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/7878e058
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/7878e058

Branch: refs/heads/master
Commit: 7878e058b154cfe43e52fd0bdd1e327583cf58fc
Parents: 4626716
Author: Leif Hedstrom <zwoop@apache.org>
Authored: Mon Nov 18 16:17:32 2013 -0700
Committer: Leif Hedstrom <zwoop@apache.org>
Committed: Mon Nov 18 16:18:20 2013 -0700

----------------------------------------------------------------------
 .../api/TSMimeHdrFieldValueStringGet.en.rst     | 108 +++++++++++++++++++
 doc/reference/api/index.en.rst                  |   1 +
 .../working-with-http-headers.en.rst            |   2 +-
 example/append-transform/append-transform.c     |   2 +-
 example/basic-auth/basic-auth.c                 |   2 +-
 example/remap/remap.cc                          |   4 +-
 example/response-header-1/response-header-1.c   |   2 +-
 example/thread-pool/psi.c                       |   2 +-
 plugins/experimental/authproxy/utils.cc         |   4 +-
 plugins/experimental/balancer/hashkey.h         |   2 +-
 .../experimental/buffer_upload/buffer_upload.cc |   2 +-
 .../custom_redirect/custom_redirect.cc          |   2 +-
 plugins/experimental/esi/combo_handler.cc       |   2 +-
 plugins/experimental/lua/lapi.cc                |   2 +-
 .../memcached_remap/memcached_remap.cc          |   4 +-
 plugins/experimental/metalink/metalink.cc       |   2 +-
 plugins/experimental/mysql_remap/mysql_remap.cc |   2 +-
 plugins/experimental/spdy/http.cc               |   2 +-
 plugins/gzip/gzip.cc                            |   2 +-
 plugins/header_filter/rules.cc                  |   2 +-
 plugins/header_rewrite/conditions.cc            |   5 +-
 proxy/InkAPITest.cc                             |  11 +-
 22 files changed, 141 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/doc/reference/api/TSMimeHdrFieldValueStringGet.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/api/TSMimeHdrFieldValueStringGet.en.rst b/doc/reference/api/TSMimeHdrFieldValueStringGet.en.rst
new file mode 100644
index 0000000..aacc6af
--- /dev/null
+++ b/doc/reference/api/TSMimeHdrFieldValueStringGet.en.rst
@@ -0,0 +1,108 @@
+.. 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.
+
+.. default-domain:: c
+
+============================
+TSMimeHdrFieldValueStringGet
+============================
+
+
+Synopsis
+========
+
+`#include <ts/ts.h>`
+
+.. function::  const char* TSMimeHdrFieldValueStringGet(TSMBuffer bufp, TSMLoc hdr, TSMLoc
field, int idx, int* value_len_ptr)
+.. function::  int TSMimeHdrFieldValueIntGet(TSMBuffer bufp, TSMLoc hdr, TSMLoc field, int
idx)
+.. function::  int64_t TSMimeHdrFieldValueInt64Get(TSMBuffer bufp, TSMLoc hdr, TSMLoc field,
int idx)
+.. function::  unsigned int TSMimeHdrFieldValueUintGet(TSMBuffer bufp, TSMLoc hdr, TSMLoc
field, int idx)
+.. function::  time_t TSMimeHdrFieldValueDateGet(TSMBuffer bufp, TSMLoc hdr, TSMLoc field)
+
+
+Description
+===========
+
+MIME headers and fields can be components of request headers, response
+headers, or standalone headers created within your plugin. The various
+functions here are all used to access header values of specific types, but it
+is up to the caller to know if a header has appropriate semantics for the API
+used. For all but :func:`TSMimeHdrFieldValueStringGet`, an appropriate data
+conversion algorithm is applied to the header field string.
+
+All APIs takes an argument with the :type:`TSMBuffer` marshal buffer, and the
+:type:`TSMLoc` for the location to headers. In addition, the required
+:data:`field` argument is the locator of a specific header value, as returned
+by e.g. :func:`TSMimeHdrFieldFind`.
+
+Within the header field, comma separated values can be retrieved with an index
+(:data:`idx`) ranging from 0 to the max number of fields for this value; this
+max is retrieved using :func:`TSMimeHdrFieldValuesCount`. An :data:`idx` value of
+``-1`` has the semantics of retrieving the entire header value, regardless of
+how many comma separated values there are. If a header is not comma separated,
+an :data:`idx` of :data:`0` or :data:`-1` are the same, but the latter is
+definitely preferred and recommended.
+
+For :func:`TSMimeHdrFieldValueStringGet`, an additional parameter can be
+provided, which is populated with the length of the string returned. If this
+argument is NULL, it is not derefenced and no length is returned.
+
+
+Return values
+=============
+
+All functions returns the header value with a type matching the respective
+function name. Using :func:`TSMimeHdrFieldValueDateGet` on a header which
+does not have date-time semantics always returns :data:`0`.
+
+
+
+Examples
+========
+
+::
+
+    #include <string.h>
+    #include <ts/ts.h>
+
+    int
+    get_content_type(TSHttpTxn txnp, char* buf)
+    {
+      TSMBuffer bufp;
+      TSMLoc hdrs;
+      TSMLoc ctype_field;
+      int len = -1;
+
+      if (TS_SUCCESS == TSHttpTxnServerRespGet(txnp, &bufp, &hdrs)) {
+        ctype_field = TSMimeHdrFieldFind(bufp, hdrs, TS_MIME_FIELD_CONTENT_TYPE, TS_MIME_LEN_CONTENT_TYPE);
+
+        if (TS_NULL_MLOC != ctype_field) {
+          const char* str = TSMimeHdrFieldValueStringGet(bufp, hdrs, ctype_field, -1, &len);
+
+          memcpy(buf, str, len);
+          TSHandleMLocRelease(bufp, hdrs, ctype_field);
+        }
+        TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdrs);
+      }
+
+      return len;
+    }
+
+
+See also
+========
+
+:manpage:`TSAPI(3ts)`, :manpage:`TSMBufferCreate(3ts)`, :manpage:`TSMimeHdrFieldValuesCount`

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/doc/reference/api/index.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/api/index.en.rst b/doc/reference/api/index.en.rst
index 3509312..7414411 100644
--- a/doc/reference/api/index.en.rst
+++ b/doc/reference/api/index.en.rst
@@ -29,6 +29,7 @@ API Reference
   TSIOBufferCreate.en
   TSInstallDirGet.en
   TSMBufferCreate.en
+  TSMimeHdrFieldValueStringGet.en
   TSPluginInit.en
   TSRemap.en
   TSTrafficServerVersionGet.en

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/doc/sdk/header-based-plugin-examples/basic-authorization-plugin/working-with-http-headers.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/header-based-plugin-examples/basic-authorization-plugin/working-with-http-headers.en.rst
b/doc/sdk/header-based-plugin-examples/basic-authorization-plugin/working-with-http-headers.en.rst
index a3b382c..207ea73 100644
--- a/doc/sdk/header-based-plugin-examples/basic-authorization-plugin/working-with-http-headers.en.rst
+++ b/doc/sdk/header-based-plugin-examples/basic-authorization-plugin/working-with-http-headers.en.rst
@@ -50,7 +50,7 @@ are present and valid:
 ::
 
     :::c
-    val = TSMimeHdrFieldValueStringGet (bufp, hdr_loc, field_loc, 0, &authval_length);
+    val = TSMimeHdrFieldValueStringGet (bufp, hdr_loc, field_loc, -1, &authval_length);
     if (!val) {
         TSError ("no value in Proxy-Authorization field\n");
         TSHandleMLocRelease (bufp, hdr_loc, field_loc);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/example/append-transform/append-transform.c
----------------------------------------------------------------------
diff --git a/example/append-transform/append-transform.c b/example/append-transform/append-transform.c
index 31d78e6..77ba97f 100644
--- a/example/append-transform/append-transform.c
+++ b/example/append-transform/append-transform.c
@@ -268,7 +268,7 @@ transformable(TSHttpTxn txnp)
       return 0;
     }
 
-    value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, 0, &val_length);
+    value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, -1, &val_length);
     if (value && (strncasecmp(value, "text/html", sizeof("text/html") - 1) == 0))
{
       ASSERT_SUCCESS(TSHandleMLocRelease(bufp, hdr_loc, field_loc));
       ASSERT_SUCCESS(TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc));

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/example/basic-auth/basic-auth.c
----------------------------------------------------------------------
diff --git a/example/basic-auth/basic-auth.c b/example/basic-auth/basic-auth.c
index 5b3cda0..963b78e 100644
--- a/example/basic-auth/basic-auth.c
+++ b/example/basic-auth/basic-auth.c
@@ -107,7 +107,7 @@ handle_dns(TSHttpTxn txnp, TSCont contp)
     goto done;
   }
 
-  val = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, 0, &authval_length);
+  val = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, -1, &authval_length);
   if (NULL == val) {
     TSError("no value in Proxy-Authorization field\n");
     TSHandleMLocRelease(bufp, hdr_loc, field_loc);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/example/remap/remap.cc
----------------------------------------------------------------------
diff --git a/example/remap/remap.cc b/example/remap/remap.cc
index add7b1f..941bcaa 100644
--- a/example/remap/remap.cc
+++ b/example/remap/remap.cc
@@ -293,12 +293,12 @@ TSRemapDoRemap(void* ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
 
   if ((cfield = TSMimeHdrFieldFind(rri->requestBufp, rri->requestHdrp, TS_MIME_FIELD_DATE,
-1)) != TS_NULL_MLOC) {
     fprintf(stderr, "We have \"Date\" header in request\n");
-    value = TSMimeHdrFieldValueStringGet(rri->requestBufp, rri->requestHdrp, cfield,
0, NULL);
+    value = TSMimeHdrFieldValueStringGet(rri->requestBufp, rri->requestHdrp, cfield,
-1, NULL);
     fprintf(stderr, "Header value: %s\n", value);
   }
   if ((cfield = TSMimeHdrFieldFind(rri->requestBufp, rri->requestHdrp, "MyHeader",
sizeof("MyHeader") - 1)) != TS_NULL_MLOC) {
     fprintf(stderr, "We have \"MyHeader\" header in request\n");
-    value = TSMimeHdrFieldValueStringGet(rri->requestBufp, rri->requestHdrp, cfield,
0, NULL);
+    value = TSMimeHdrFieldValueStringGet(rri->requestBufp, rri->requestHdrp, cfield,
-1, NULL);
     fprintf(stderr, "Header value: %s\n", value);
   }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/example/response-header-1/response-header-1.c
----------------------------------------------------------------------
diff --git a/example/response-header-1/response-header-1.c b/example/response-header-1/response-header-1.c
index 68c1d11..814c2d2 100644
--- a/example/response-header-1/response-header-1.c
+++ b/example/response-header-1/response-header-1.c
@@ -157,7 +157,7 @@ modify_header(TSHttpTxn txnp)
     }
 
     /* Get the cached MIME value for this name in this HTTP header */
-    chkptr = TSMimeHdrFieldValueStringGet(cached_bufp, cached_loc, cached_field_loc, 0, &chklength);
+    chkptr = TSMimeHdrFieldValueStringGet(cached_bufp, cached_loc, cached_field_loc, -1,
&chklength);
     if (NULL == chkptr || !chklength) {
       TSError("Could not find value for cached MIME field name %s", mimehdr1_name);
       TSHandleMLocRelease(resp_bufp, TS_NULL_MLOC, resp_loc);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/example/thread-pool/psi.c
----------------------------------------------------------------------
diff --git a/example/thread-pool/psi.c b/example/thread-pool/psi.c
index fb84a4a..24fef91 100644
--- a/example/thread-pool/psi.c
+++ b/example/thread-pool/psi.c
@@ -911,7 +911,7 @@ transformable(TSHttpTxn txnp)
     return 0;
   }
 
-  value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, 0, NULL);
+  value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, -1, NULL);
   if ((value == NULL) || (strncasecmp(value, "text/", sizeof("text/") - 1) != 0)) {
     TSHandleMLocRelease(bufp, hdr_loc, field_loc);
     TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/experimental/authproxy/utils.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/authproxy/utils.cc b/plugins/experimental/authproxy/utils.cc
index 315477d..d55e1af 100644
--- a/plugins/experimental/authproxy/utils.cc
+++ b/plugins/experimental/authproxy/utils.cc
@@ -163,7 +163,7 @@ HttpIsChunkedEncoding(TSMBuffer mbuf, TSMLoc mhdr)
         const char * str;
         int len;
 
-        str = TSMimeHdrFieldValueStringGet(mbuf, mhdr, mloc, 0 /* index */, &len);
+        str = TSMimeHdrFieldValueStringGet(mbuf, mhdr, mloc, -1 /* index */, &len);
         if (str && len) {
             ischunked = (strncmp("chunked", str, len) == 0);
         }
@@ -184,7 +184,7 @@ HttpGetOriginHost(TSMBuffer mbuf, TSMLoc mhdr, char * name, size_t namelen)
     // depends on whether pristine_host_hdr is set.
     mloc = TSMimeHdrFieldFind(mbuf, mhdr, TS_MIME_FIELD_HOST, -1);
     if (mloc != TS_NULL_MLOC) {
-        host = TSMimeHdrFieldValueStringGet(mbuf, mhdr, mloc, 0 /* index */, &len);
+        host = TSMimeHdrFieldValueStringGet(mbuf, mhdr, mloc, -1 /* index */, &len);
         TSHandleMLocRelease(mbuf, mhdr, mloc);
 
         if (host) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/experimental/balancer/hashkey.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/balancer/hashkey.h b/plugins/experimental/balancer/hashkey.h
index 856c84f..f4b516a 100644
--- a/plugins/experimental/balancer/hashkey.h
+++ b/plugins/experimental/balancer/hashkey.h
@@ -223,7 +223,7 @@ class HeaderHashKey : public HashKey
     // Note that hdrLoc is freed as part of the Resources dtor, and we free the "string"
value
     // in the free_key() implementation (after we're done with it).
     if (bufp && hdrLoc && (fieldLoc = TSMimeHdrFieldFind(bufp, hdrLoc, _header,
_header_len))) {
-      if (TS_ERROR != TSMimeHdrFieldValueStringGet(bufp, hdrLoc, fieldLoc, 0, &val, &len))
{
+      if (TS_ERROR != TSMimeHdrFieldValueStringGet(bufp, hdrLoc, fieldLoc, -1, &val,
&len)) {
         *data = val;
       } else {
         *data = NULL;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/experimental/buffer_upload/buffer_upload.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/buffer_upload/buffer_upload.cc b/plugins/experimental/buffer_upload/buffer_upload.cc
index 10d400e..ae346bb 100644
--- a/plugins/experimental/buffer_upload/buffer_upload.cc
+++ b/plugins/experimental/buffer_upload/buffer_upload.cc
@@ -749,7 +749,7 @@ attach_pvc_plugin(TSCont /* contp ATS_UNUSED */, TSEvent event, void *edata)
           TSHandleMLocRelease(req_bufp, TS_NULL_MLOC, req_loc);
           break;
         }
-        host_hdr_str_val = TSMimeHdrFieldValueStringGet(req_bufp, req_loc, field_loc, 0,
&host_hdr_str_val_len);
+        host_hdr_str_val = TSMimeHdrFieldValueStringGet(req_bufp, req_loc, field_loc, -1,
&host_hdr_str_val_len);
         if (NOT_VALID_PTR(host_hdr_str_val) || host_hdr_str_val_len <= 0) {
           //if (VALID_PTR(str))
           //  TSHandleStringRelease(req_bufp, field_loc, str);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/experimental/custom_redirect/custom_redirect.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/custom_redirect/custom_redirect.cc b/plugins/experimental/custom_redirect/custom_redirect.cc
index ea02333..5ccf8ef 100644
--- a/plugins/experimental/custom_redirect/custom_redirect.cc
+++ b/plugins/experimental/custom_redirect/custom_redirect.cc
@@ -68,7 +68,7 @@ handle_response (TSHttpTxn txnp, TSCont /* contp ATS_UNUSED */)
                   redirect_url_loc = TSMimeHdrFieldFind (resp_bufp, resp_loc, redirect_url_header,
redirect_url_header_len);
 
                     if (redirect_url_loc) {
-                        redirect_url_str = TSMimeHdrFieldValueStringGet (resp_bufp, resp_loc,
redirect_url_loc, 0, &redirect_url_length);
+                        redirect_url_str = TSMimeHdrFieldValueStringGet (resp_bufp, resp_loc,
redirect_url_loc, -1, &redirect_url_length);
                         if (redirect_url_str) {
                             if (redirect_url_length > 0) {
                               TSRedirectUrlSet(txnp, redirect_url_str, redirect_url_length);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/experimental/esi/combo_handler.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/esi/combo_handler.cc b/plugins/experimental/esi/combo_handler.cc
index e14c04c..ca218af 100644
--- a/plugins/experimental/esi/combo_handler.cc
+++ b/plugins/experimental/esi/combo_handler.cc
@@ -349,7 +349,7 @@ getDefaultBucket(TSHttpTxn /* txnp ATS_UNUSED */, TSMBuffer bufp, TSMLoc
hdr_obj
     return false;
   }
 
-  host = TSMimeHdrFieldValueStringGet(bufp, hdr_obj, field_loc, 0, &host_len);
+  host = TSMimeHdrFieldValueStringGet(bufp, hdr_obj, field_loc, -1, &host_len);
   if (!host || host_len <= 0) {
     LOG_ERROR("Error Extracting Host Header");
     TSHandleMLocRelease (bufp, hdr_obj, field_loc);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/experimental/lua/lapi.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/lua/lapi.cc b/plugins/experimental/lua/lapi.cc
index c284429..efa1b3d 100644
--- a/plugins/experimental/lua/lapi.cc
+++ b/plugins/experimental/lua/lapi.cc
@@ -389,7 +389,7 @@ LuaRemapHeaderIndex(lua_State * lua)
     return 1;
   }
 
-  value = TSMimeHdrFieldValueStringGet(hdrs->buffer, hdrs->headers, field, 0, &vlen);
+  value = TSMimeHdrFieldValueStringGet(hdrs->buffer, hdrs->headers, field, -1, &vlen);
   lua_pushlstring(lua, value, vlen);
   return 1;
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/experimental/memcached_remap/memcached_remap.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/memcached_remap/memcached_remap.cc b/plugins/experimental/memcached_remap/memcached_remap.cc
index 7e63812..d7495c2 100644
--- a/plugins/experimental/memcached_remap/memcached_remap.cc
+++ b/plugins/experimental/memcached_remap/memcached_remap.cc
@@ -70,9 +70,7 @@ bool do_memcached_remap(TSCont contp, TSHttpTxn txnp)
         goto release_url;
     }
 
-    request_host =
-        TSMimeHdrFieldValueStringGet(reqp, hdr_loc, field_loc, 0,
-                                     &request_host_length);
+    request_host = TSMimeHdrFieldValueStringGet(reqp, hdr_loc, field_loc, -1, &request_host_length);
     if (request_host == NULL || strlen(request_host) < 1) {
         TSDebug(PLUGIN_NAME, "couldn't find request HOST header");
         goto release_field;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/experimental/metalink/metalink.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/metalink/metalink.cc b/plugins/experimental/metalink/metalink.cc
index 86747ef..18ad584 100644
--- a/plugins/experimental/metalink/metalink.cc
+++ b/plugins/experimental/metalink/metalink.cc
@@ -565,7 +565,7 @@ http_send_response_hdr(TSCont contp, void *edata)
   /* If can't parse or lookup "Location: ..." URL, should still check if
    * response has "Digest: SHA-256=..." header? No: Can't parse or lookup URL
    * in "Location: ..." header is error */
-  value = TSMimeHdrFieldValueStringGet(data->resp_bufp, data->hdr_loc, data->location_loc,
0, &length);
+  value = TSMimeHdrFieldValueStringGet(data->resp_bufp, data->hdr_loc, data->location_loc,
-1, &length);
   if (TSUrlParse(data->resp_bufp, data->url_loc, &value, value + length) != TS_PARSE_DONE)
{
 
     TSHandleMLocRelease(data->resp_bufp, TS_NULL_MLOC, data->url_loc);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/experimental/mysql_remap/mysql_remap.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/mysql_remap/mysql_remap.cc b/plugins/experimental/mysql_remap/mysql_remap.cc
index 848537d..c93274e 100644
--- a/plugins/experimental/mysql_remap/mysql_remap.cc
+++ b/plugins/experimental/mysql_remap/mysql_remap.cc
@@ -68,7 +68,7 @@ bool do_mysql_remap(TSCont contp,TSHttpTxn txnp) {
       goto release_url;
   }
   
-  request_host = TSMimeHdrFieldValueStringGet (reqp, hdr_loc, field_loc, 0, &request_host_length);
+  request_host = TSMimeHdrFieldValueStringGet (reqp, hdr_loc, field_loc, -1, &request_host_length);
   if (!request_host_length) {
     TSDebug(PLUGIN_NAME,"couldn't find request HOST header");
     goto release_field;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/experimental/spdy/http.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/spdy/http.cc b/plugins/experimental/spdy/http.cc
index db17249..64d46de 100644
--- a/plugins/experimental/spdy/http.cc
+++ b/plugins/experimental/spdy/http.cc
@@ -90,7 +90,7 @@ http_send_response(
         }
 
         value.first = TSMimeHdrFieldValueStringGet(buffer, header,
-                field, 0, &value.second);
+                field, -1, &value.second);
         kvblock.insert(std::string(name.first, name.second),
                 std::string(value.first, value.second));
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/gzip/gzip.cc
----------------------------------------------------------------------
diff --git a/plugins/gzip/gzip.cc b/plugins/gzip/gzip.cc
index 9c84dc8..ac654f7 100644
--- a/plugins/gzip/gzip.cc
+++ b/plugins/gzip/gzip.cc
@@ -555,7 +555,7 @@ gzip_transformable(TSHttpTxn txnp, int server, HostConfiguration * host_configur
     return 0;
   }
 
-  value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, 0, &len);
+  value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, -1, &len);
 
   int rv = host_configuration->ContentTypeIsCompressible(value, len);
   if (!rv) { 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/header_filter/rules.cc
----------------------------------------------------------------------
diff --git a/plugins/header_filter/rules.cc b/plugins/header_filter/rules.cc
index 62c21cb..feebc04 100644
--- a/plugins/header_filter/rules.cc
+++ b/plugins/header_filter/rules.cc
@@ -77,7 +77,7 @@ RulesEntry::execute(TSMBuffer& reqp, TSMLoc& hdr_loc) const
         bool nuke = false;
       
         if (_q_type != QUAL_NONE)
-          val = TSMimeHdrFieldValueStringGet(reqp, hdr_loc, field, 0, &val_len);
+          val = TSMimeHdrFieldValueStringGet(reqp, hdr_loc, field, -1, &val_len);
 
         switch (_q_type) {
         case QUAL_NONE:

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/header_rewrite/conditions.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/conditions.cc b/plugins/header_rewrite/conditions.cc
index f57e6e9..4ff38b6 100644
--- a/plugins/header_rewrite/conditions.cc
+++ b/plugins/header_rewrite/conditions.cc
@@ -192,7 +192,7 @@ ConditionHeader::append_value(std::string& s, const Resources&
res)
     field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, _qualifier.c_str(), _qualifier.size());
     TSDebug(PLUGIN_NAME, "Getting Header: %s, field_loc: %p", _qualifier.c_str(), field_loc);
     if (field_loc != NULL) {
-      value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, 0, &len);
+      value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, -1, &len);
       TSDebug(PLUGIN_NAME, "Appending HEADER(%s) to evaluation value -> %.*s", _qualifier.c_str(),
len, value);
       s.append(value, len);
       TSHandleMLocRelease(bufp, hdr_loc, field_loc);
@@ -423,8 +423,7 @@ void ConditionCookie::append_value(std::string& s, const Resources&
res)
     return;
 
   // Get all cookies
-  // NB! Cookie field does not support commas, so we use index == 0
-  cookies = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, 0, &cookies_len);
+  cookies = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, -1, &cookies_len);
   if (cookies == NULL || cookies_len <= 0)
     goto out_release_field;
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/proxy/InkAPITest.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPITest.cc b/proxy/InkAPITest.cc
index 9bbf6a5..3e0ce3a 100644
--- a/proxy/InkAPITest.cc
+++ b/proxy/InkAPITest.cc
@@ -3688,6 +3688,7 @@ REGRESSION_TEST(SDK_API_TSMimeHdrField) (RegressionTest * test, int
/* atype ATS
   const char *field1Value3Get;
   const char *field1Value4Get;
   const char *field1Value5Get;
+  const char *field1ValueAllGet;
   const char *field1ValueNewGet;
 
   int lengthField1Value1;
@@ -3695,6 +3696,7 @@ REGRESSION_TEST(SDK_API_TSMimeHdrField) (RegressionTest * test, int
/* atype ATS
   int lengthField1Value3;
   int lengthField1Value4;
   int lengthField1Value5;
+  int lengthField1ValueAll;
   int lengthField1ValueNew;
 
   time_t field2Value1 = time(NULL);
@@ -3996,13 +3998,20 @@ REGRESSION_TEST(SDK_API_TSMimeHdrField) (RegressionTest * test, int
/* atype ATS
       field1Value3Get = TSMimeHdrFieldValueStringGet(bufp1, mime_loc1, field_loc11, 2, &lengthField1Value3);
       field1Value4Get = TSMimeHdrFieldValueStringGet(bufp1, mime_loc1, field_loc11, 3, &lengthField1Value4);
       field1Value5Get = TSMimeHdrFieldValueStringGet(bufp1, mime_loc1, field_loc11, 4, &lengthField1Value5);
+      field1ValueAllGet = TSMimeHdrFieldValueStringGet(bufp1, mime_loc1, field_loc11, -1,
&lengthField1ValueAll);
       if (((strncmp(field1Value1Get, field1Value1, lengthField1Value1) == 0) && lengthField1Value1
== (int) strlen(field1Value1)) &&
           ((strncmp(field1Value2Get, field1Value2, lengthField1Value2) == 0) && lengthField1Value2
== (int) strlen(field1Value2)) &&
           ((strncmp(field1Value3Get, field1Value3, lengthField1Value3) == 0) && lengthField1Value3
== (int) strlen(field1Value3)) &&
           ((strncmp(field1Value4Get, field1Value4, lengthField1Value4) == 0) && lengthField1Value4
== (int) strlen(field1Value4)) &&
-          ((strncmp(field1Value5Get, field1Value5, lengthField1Value5) == 0) && lengthField1Value5
== (int) strlen(field1Value5))) {
+          ((strncmp(field1Value5Get, field1Value5, lengthField1Value5) == 0) && lengthField1Value5
== (int) strlen(field1Value5)) &&
+          (strstr(field1ValueAllGet, field1Value1Get) == field1Value1Get) &&
+          (strstr(field1ValueAllGet, field1Value2Get) == field1Value2Get) &&
+          (strstr(field1ValueAllGet, field1Value3Get) == field1Value3Get) &&
+          (strstr(field1ValueAllGet, field1Value4Get) == field1Value4Get) &&
+          (strstr(field1ValueAllGet, field1Value5Get) == field1Value5Get)) {
         SDK_RPRINT(test, "TSMimeHdrFieldValueStringInsert", "TestCase1&2&3&4&5",
TC_PASS, "ok");
         SDK_RPRINT(test, "TSMimeHdrFieldValueStringGet", "TestCase1&2&3&4&5",
TC_PASS, "ok");
+        SDK_RPRINT(test, "TSMimeHdrFieldValueStringGet with IDX=-1", "TestCase1&2&3&4&5",
TC_PASS, "ok");
         test_passed_Mime_Hdr_Field_Value_String_Insert = true;
         test_passed_Mime_Hdr_Field_Value_String_Get = true;
 


Mime
View raw message