This is an automated email from the ASF dual-hosted git repository.
bnolsen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new abf073f911 Fix for fetchsm chunked response handling with dechunking
turned off (#12707)
abf073f911 is described below
commit abf073f91137749ee3c695a56adf3b1754f8c3c3
Author: Brian Olsen <[email protected]>
AuthorDate: Tue Dec 2 16:42:49 2025 -0700
Fix for fetchsm chunked response handling with dechunking turned off
(#12707)
* FetchSM: fix for chunked response but no dechunking
* add lua support so that the fetchsm code can be tested
---------
Co-authored-by: Brian Olsen <[email protected]>
---
doc/admin-guide/plugins/lua.en.rst | 6 ++++--
plugins/lua/ts_lua_fetch.cc | 3 +++
src/proxy/FetchSM.cc | 13 +++++++++----
3 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/doc/admin-guide/plugins/lua.en.rst
b/doc/admin-guide/plugins/lua.en.rst
index 0df84ed3c9..b00999633e 100644
--- a/doc/admin-guide/plugins/lua.en.rst
+++ b/doc/admin-guide/plugins/lua.en.rst
@@ -3864,11 +3864,13 @@ We can set the optional table with several members:
``cliaddr`` holds the request client address in ip:port form. The default
cliaddr is '127.0.0.1:33333'
-Issuing a post request:
+``option`` holds request options. 'c' is to not dechunk chunked content, 's'
is to skip remap config and go direct.
+
+Issuing a direct post request:
::
- res = ts.fetch('http://xx.com/foo', {method = 'POST', body = 'hello
world'})
+ res = ts.fetch('http://xx.com/foo', {method = 'POST', body = 'hello
world', option = 's' })
:ref:`TOP <admin-plugins-ts-lua>`
diff --git a/plugins/lua/ts_lua_fetch.cc b/plugins/lua/ts_lua_fetch.cc
index 38b0b3802e..b14b918eab 100644
--- a/plugins/lua/ts_lua_fetch.cc
+++ b/plugins/lua/ts_lua_fetch.cc
@@ -298,6 +298,9 @@ ts_lua_fetch_one_item(lua_State *L, const char *url, size_t
url_len, ts_lua_fetc
case 'c':
flags &= (~TS_FETCH_FLAGS_DECHUNK);
break;
+ case 's':
+ flags |= (TS_FETCH_FLAGS_SKIP_REMAP);
+ break;
default:
break;
diff --git a/src/proxy/FetchSM.cc b/src/proxy/FetchSM.cc
index 6880b5570d..66b800fd6a 100644
--- a/src/proxy/FetchSM.cc
+++ b/src/proxy/FetchSM.cc
@@ -293,6 +293,9 @@ FetchSM::InvokePluginExt(int fetch_event)
MUTEX_TAKE_LOCK(cont_mutex, mythread);
}
+ bool const dechunk = 0 != (fetch_flags & TS_FETCH_FLAGS_DECHUNK);
+ bool chunked = false;
+
if (!contp) {
goto out;
}
@@ -328,11 +331,13 @@ FetchSM::InvokePluginExt(int fetch_event)
goto out;
}
+ chunked = check_chunked();
+
Dbg(dbg_ctl, "[%s] chunked:%d, content_len: %" PRId64 ", received_len: %"
PRId64 ", avail: %" PRId64 "", __FUNCTION__,
resp_is_chunked, resp_content_length, resp_received_body_len,
- resp_is_chunked > 0 ? chunked_handler.chunked_reader->read_avail() :
resp_reader->read_avail());
+ chunked && dechunk ? chunked_handler.chunked_reader->read_avail() :
resp_reader->read_avail());
- if (resp_is_chunked > 0) {
+ if (chunked && dechunk) {
if (!chunked_handler.chunked_reader->read_avail()) {
if (read_complete_event) {
contp->handleEvent(TS_FETCH_EVENT_EXT_BODY_DONE, this);
@@ -346,13 +351,13 @@ FetchSM::InvokePluginExt(int fetch_event)
goto out;
}
- if (!check_chunked()) {
+ if (!chunked) {
if (!check_body_done() && !read_complete_event) {
contp->handleEvent(TS_FETCH_EVENT_EXT_BODY_READY, this);
} else {
contp->handleEvent(TS_FETCH_EVENT_EXT_BODY_DONE, this);
}
- } else if (fetch_flags & TS_FETCH_FLAGS_DECHUNK) {
+ } else if (dechunk) {
do {
if (chunked_handler.state == ChunkedHandler::ChunkedState::FLOW_CONTROL)
{
chunked_handler.state = ChunkedHandler::ChunkedState::READ_SIZE_START;