You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jd...@apache.org on 2026/10/09 15:53:32 UTC

(trafficserver) 01/01: api: expose the QUERY method to plugins

This is an automated email from the ASF dual-hosted git repository.

JakeChampion pushed a commit to branch jake/query-plugin-api
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 4c637b24746689868d19a11b0e88c90b6d3fc3f4
Author: jake champion <ja...@netlify.com>
AuthorDate: Tue Aug 18 16:29:53 2026 +0100

    api: expose the QUERY method to plugins
    
    Add TS_HTTP_METHOD_QUERY and TS_HTTP_LEN_QUERY to the C API, QUERY to
    the cripts method constants, and QUERY to the C++ API's HttpMethod
    enum, so plugins can compare against the pre-allocated method name the
    way they do for the other well-known methods.
    
    The HttpMethod enumerator is appended rather than inserted next to
    PURGE so the existing enumerator values do not shift.
---
 doc/developer-guide/plugins/http-headers/header-functions.en.rst | 3 +++
 doc/release-notes/whats-new.en.rst                               | 2 ++
 include/cripts/Headers.hpp                                       | 1 +
 include/ts/apidefs.h.in                                          | 1 +
 include/tscpp/api/HttpMethod.h                                   | 3 ++-
 src/api/InkAPIInternal.cc                                        | 4 ++++
 src/cripts/Headers.cc                                            | 1 +
 src/tscpp/api/HttpMethod.cc                                      | 2 +-
 src/tscpp/api/Request.cc                                         | 2 ++
 9 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/doc/developer-guide/plugins/http-headers/header-functions.en.rst b/doc/developer-guide/plugins/http-headers/header-functions.en.rst
index 47d07459a2..de6db7389f 100644
--- a/doc/developer-guide/plugins/http-headers/header-functions.en.rst
+++ b/doc/developer-guide/plugins/http-headers/header-functions.en.rst
@@ -71,6 +71,9 @@ the methods defined in the HTTP 1.1 specification
 ``TS_HTTP_METHOD_PUSH``
    "PUSH"
 
+``TS_HTTP_METHOD_QUERY``
+   "QUERY"
+
 Traffic Server also defines several common values that appear in HTTP
 headers.
 
diff --git a/doc/release-notes/whats-new.en.rst b/doc/release-notes/whats-new.en.rst
index 6ef94b1115..99532d1333 100644
--- a/doc/release-notes/whats-new.en.rst
+++ b/doc/release-notes/whats-new.en.rst
@@ -73,6 +73,8 @@ TS API
 * Add ``TSVConnPPInfoGet`` to get Proxy Protocol information.
 * Add ``TSContScheduleOnEntirePool`` and ``TSContScheduleEveryOnEntirePool`` to
   schedule continuations on every thread in a pool.
+* Add ``TS_HTTP_METHOD_QUERY`` and ``TS_HTTP_LEN_QUERY`` for the HTTP ``QUERY``
+  method, along with the corresponding cripts and C++ API constants.
 
 Features
 --------
diff --git a/include/cripts/Headers.hpp b/include/cripts/Headers.hpp
index b1010cf855..3278bbbbad 100644
--- a/include/cripts/Headers.hpp
+++ b/include/cripts/Headers.hpp
@@ -531,6 +531,7 @@ namespace Method
   extern const cripts::Header::Method TRACE;
   // This is a special feature of ATS
   extern const cripts::Header::Method PURGE;
+  extern const cripts::Header::Method QUERY;
 } // namespace Method
 
 // Lookup status constants, these are used in the Cache::Response::lookupstatus
diff --git a/include/ts/apidefs.h.in b/include/ts/apidefs.h.in
index 86bb8e2af1..c6b8557301 100644
--- a/include/ts/apidefs.h.in
+++ b/include/ts/apidefs.h.in
@@ -1491,6 +1491,7 @@ extern const char *TS_HTTP_METHOD_PURGE;
 extern const char *TS_HTTP_METHOD_PUT;
 extern const char *TS_HTTP_METHOD_TRACE;
 extern const char *TS_HTTP_METHOD_PUSH;
+extern const char *TS_HTTP_METHOD_QUERY;
 
 /* --------------------------------------------------------------------------
    HTTP methods string lengths */
diff --git a/include/tscpp/api/HttpMethod.h b/include/tscpp/api/HttpMethod.h
index 59a6fb7857..27b94ed65f 100644
--- a/include/tscpp/api/HttpMethod.h
+++ b/include/tscpp/api/HttpMethod.h
@@ -43,7 +43,8 @@ enum HttpMethod {
   HTTP_METHOD_PURGE,
   HTTP_METHOD_PUT,
   HTTP_METHOD_TRACE,
-  HTTP_METHOD_PUSH
+  HTTP_METHOD_PUSH,
+  HTTP_METHOD_QUERY
 };
 
 /**
diff --git a/src/api/InkAPIInternal.cc b/src/api/InkAPIInternal.cc
index 8bb20a2b38..43a22ee85d 100644
--- a/src/api/InkAPIInternal.cc
+++ b/src/api/InkAPIInternal.cc
@@ -285,6 +285,7 @@ const char *TS_HTTP_METHOD_PURGE;
 const char *TS_HTTP_METHOD_PUT;
 const char *TS_HTTP_METHOD_TRACE;
 const char *TS_HTTP_METHOD_PUSH;
+const char *TS_HTTP_METHOD_QUERY;
 
 /* HTTP methods string lengths */
 int TS_HTTP_LEN_CONNECT;
@@ -297,6 +298,7 @@ int TS_HTTP_LEN_PURGE;
 int TS_HTTP_LEN_PUT;
 int TS_HTTP_LEN_TRACE;
 int TS_HTTP_LEN_PUSH;
+int TS_HTTP_LEN_QUERY;
 
 ////////////////////////////////////////////////////////////////////
 //
@@ -730,6 +732,7 @@ api_init()
     TS_HTTP_METHOD_PUT     = HTTP_METHOD_PUT.c_str();
     TS_HTTP_METHOD_TRACE   = HTTP_METHOD_TRACE.c_str();
     TS_HTTP_METHOD_PUSH    = HTTP_METHOD_PUSH.c_str();
+    TS_HTTP_METHOD_QUERY   = HTTP_METHOD_QUERY.c_str();
 
     TS_HTTP_LEN_CONNECT = static_cast<int>(HTTP_METHOD_CONNECT.length());
     TS_HTTP_LEN_DELETE  = static_cast<int>(HTTP_METHOD_DELETE.length());
@@ -741,6 +744,7 @@ api_init()
     TS_HTTP_LEN_PUT     = static_cast<int>(HTTP_METHOD_PUT.length());
     TS_HTTP_LEN_TRACE   = static_cast<int>(HTTP_METHOD_TRACE.length());
     TS_HTTP_LEN_PUSH    = static_cast<int>(HTTP_METHOD_PUSH.length());
+    TS_HTTP_LEN_QUERY   = static_cast<int>(HTTP_METHOD_QUERY.length());
 
     /* HTTP miscellaneous values */
     TS_HTTP_VALUE_BYTES            = HTTP_VALUE_BYTES.c_str();
diff --git a/src/cripts/Headers.cc b/src/cripts/Headers.cc
index fb668908f2..93a4460f22 100644
--- a/src/cripts/Headers.cc
+++ b/src/cripts/Headers.cc
@@ -38,6 +38,7 @@ namespace Method
   const cripts::Header::Method OPTIONS(TS_HTTP_METHOD_OPTIONS, TS_HTTP_LEN_OPTIONS);
   const cripts::Header::Method CONNECT(TS_HTTP_METHOD_CONNECT, TS_HTTP_LEN_CONNECT);
   const cripts::Header::Method TRACE(TS_HTTP_METHOD_TRACE, TS_HTTP_LEN_TRACE);
+  const cripts::Header::Method QUERY(TS_HTTP_METHOD_QUERY, TS_HTTP_LEN_QUERY);
   // This is a special feature of ATS
   const cripts::Header::Method PURGE(TS_HTTP_METHOD_PURGE, TS_HTTP_LEN_PURGE);
 } // namespace Method
diff --git a/src/tscpp/api/HttpMethod.cc b/src/tscpp/api/HttpMethod.cc
index a1f6801646..bcbce2f336 100644
--- a/src/tscpp/api/HttpMethod.cc
+++ b/src/tscpp/api/HttpMethod.cc
@@ -25,4 +25,4 @@
 const std::string atscppapi::HTTP_METHOD_STRINGS[] = {std::string("UNKNOWN"), std::string("GET"),     std::string("POST"),
                                                       std::string("HEAD"),    std::string("CONNECT"), std::string("DELETE"),
                                                       std::string("OPTIONS"), std::string("PURGE"),   std::string("PUT"),
-                                                      std::string("TRACE"),   std::string("PUSH")};
+                                                      std::string("TRACE"),   std::string("PUSH"),    std::string("QUERY")};
diff --git a/src/tscpp/api/Request.cc b/src/tscpp/api/Request.cc
index 72ea0267fd..1782522ce2 100644
--- a/src/tscpp/api/Request.cc
+++ b/src/tscpp/api/Request.cc
@@ -128,6 +128,8 @@ Request::getMethod() const
         state_->method_ = HTTP_METHOD_OPTIONS;
       } else if (method_str == TS_HTTP_METHOD_PURGE) {
         state_->method_ = HTTP_METHOD_PURGE;
+      } else if (method_str == TS_HTTP_METHOD_QUERY) {
+        state_->method_ = HTTP_METHOD_QUERY;
       } else if (method_str == TS_HTTP_METHOD_PUT) {
         state_->method_ = HTTP_METHOD_PUT;
       } else if (method_str == TS_HTTP_METHOD_TRACE) {