Skip to content

Commit 07e02a8

Browse files
committed
Associate HttpSM with TSMLoc
Avoid the user needing to include TSHttpTxn to TSHttpHdrStatusSet by keeping track of the HttpSM per TSMLoc and using that when passed in.
1 parent 275aa4e commit 07e02a8

File tree

17 files changed

+168
-35
lines changed

17 files changed

+168
-35
lines changed

doc/developer-guide/api/functions/TSHttpHdrStatusSet.en.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Synopsis
3030
3131
.. function:: TSReturnCode TSHttpHdrStatusSet(TSMBuffer bufp, TSMLoc offset, TSHttpStatus status)
3232

33-
.. function:: TSReturnCode TSHttpHdrStatusSet(TSMBuffer bufp, TSMLoc offset, TSHttpStatus status, TSHttpTxn txnp, std::string_view setter)
33+
.. function:: TSReturnCode TSHttpHdrStatusSet(TSMBuffer bufp, TSMLoc offset, TSHttpStatus status, std::string_view setter)
3434

3535
Description
3636
===========
@@ -45,5 +45,4 @@ Parameters
4545
- bufp: Marshal buffer containing the HTTP header.
4646
- offset: Location of the HTTP header within bufp.
4747
- status: The HTTP status code to set.
48-
- txnp: Optional transaction handle on which to record the setter label.
4948
- setter: Optional label identifying the component setting the status; pass empty to leave unchanged.

example/plugins/c-api/basic_auth/basic_auth.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ handle_response(TSHttpTxn txnp)
174174
goto done;
175175
}
176176

177-
TSHttpHdrStatusSet(bufp, hdr_loc, TS_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED, txnp, PLUGIN_NAME);
177+
TSHttpHdrStatusSet(bufp, hdr_loc, TS_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED, PLUGIN_NAME);
178178
TSHttpHdrReasonSet(bufp, hdr_loc, TSHttpHdrReasonLookup(TS_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED),
179179
strlen(TSHttpHdrReasonLookup(TS_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED)));
180180

example/plugins/c-api/denylist_0/denylist_0.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ handle_response(TSHttpTxn txnp)
9999
goto done;
100100
}
101101

102-
TSHttpHdrStatusSet(bufp, hdr_loc, TS_HTTP_STATUS_FORBIDDEN, txnp, PLUGIN_NAME);
102+
TSHttpHdrStatusSet(bufp, hdr_loc, TS_HTTP_STATUS_FORBIDDEN, PLUGIN_NAME);
103103
TSHttpHdrReasonSet(bufp, hdr_loc, TSHttpHdrReasonLookup(TS_HTTP_STATUS_FORBIDDEN),
104104
strlen(TSHttpHdrReasonLookup(TS_HTTP_STATUS_FORBIDDEN)));
105105

example/plugins/c-api/denylist_1/denylist_1.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ handle_response(TSHttpTxn txnp, TSCont contp ATS_UNUSED)
145145
goto done;
146146
}
147147

148-
TSHttpHdrStatusSet(bufp, hdr_loc, TS_HTTP_STATUS_FORBIDDEN, txnp, PLUGIN_NAME);
148+
TSHttpHdrStatusSet(bufp, hdr_loc, TS_HTTP_STATUS_FORBIDDEN, PLUGIN_NAME);
149149
TSHttpHdrReasonSet(bufp, hdr_loc, TSHttpHdrReasonLookup(TS_HTTP_STATUS_FORBIDDEN),
150150
strlen(TSHttpHdrReasonLookup(TS_HTTP_STATUS_FORBIDDEN)));
151151

example/plugins/c-api/redirect_1/redirect_1.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ handle_response(TSHttpTxn txnp)
191191
goto done;
192192
}
193193

194-
TSHttpHdrStatusSet(bufp, hdr_loc, TS_HTTP_STATUS_MOVED_PERMANENTLY, txnp, PLUGIN_NAME);
194+
TSHttpHdrStatusSet(bufp, hdr_loc, TS_HTTP_STATUS_MOVED_PERMANENTLY, PLUGIN_NAME);
195195
TSHttpHdrReasonSet(bufp, hdr_loc, TSHttpHdrReasonLookup(TS_HTTP_STATUS_MOVED_PERMANENTLY),
196196
strlen(TSHttpHdrReasonLookup(TS_HTTP_STATUS_MOVED_PERMANENTLY)));
197197

include/ts/ts.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ TSReturnCode TSHttpHdrUrlSet(TSMBuffer bufp, TSMLoc offset, TSMLoc url);
11451145
TSHttpStatus TSHttpHdrStatusGet(TSMBuffer bufp, TSMLoc offset);
11461146
/** This is a candidate for deprecation in v10.0.0 in favor of the version that takes the setter. */
11471147
TSReturnCode TSHttpHdrStatusSet(TSMBuffer bufp, TSMLoc offset, TSHttpStatus status);
1148-
TSReturnCode TSHttpHdrStatusSet(TSMBuffer bufp, TSMLoc offset, TSHttpStatus status, TSHttpTxn txnp, std::string_view setter);
1148+
TSReturnCode TSHttpHdrStatusSet(TSMBuffer bufp, TSMLoc offset, TSHttpStatus status, std::string_view setter);
11491149
const char *TSHttpHdrReasonGet(TSMBuffer bufp, TSMLoc offset, int *length);
11501150
TSReturnCode TSHttpHdrReasonSet(TSMBuffer bufp, TSMLoc offset, const char *value, int length);
11511151
const char *TSHttpHdrReasonLookup(TSHttpStatus status);

plugins/experimental/icap/icap_plugin.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ handle_invalid_icap_behavior(TSCont contp, TransformData *data, const char *msg)
241241
TSError("[%s] Couldn't clear client response header", PLUGIN_NAME);
242242
return 0;
243243
}
244-
TSHttpHdrStatusSet(bufp, hdr_loc, TS_HTTP_STATUS_BAD_GATEWAY, data->txn, PLUGIN_NAME);
244+
TSHttpHdrStatusSet(bufp, hdr_loc, TS_HTTP_STATUS_BAD_GATEWAY, PLUGIN_NAME);
245245
TSHttpHdrReasonSet(bufp, hdr_loc, TSHttpHdrReasonLookup(TS_HTTP_STATUS_BAD_GATEWAY),
246246
strlen(TSHttpHdrReasonLookup(TS_HTTP_STATUS_BAD_GATEWAY)));
247247
TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);

plugins/experimental/tls_bridge/tls_bridge.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ Bridge::update_ua_response()
513513
// an actual upstream connection. Otherwise, let the original connection response code
514514
// ride.
515515
if (_out_response_code != TS_HTTP_STATUS_OK && _out_response_code != TS_HTTP_STATUS_NONE) {
516-
TSHttpHdrStatusSet(mbuf, hdr_loc, _out_response_code, _ua_txn, PLUGIN_NAME);
516+
TSHttpHdrStatusSet(mbuf, hdr_loc, _out_response_code, PLUGIN_NAME);
517517
if (!_out_response_reason.empty()) {
518518
TSHttpHdrReasonSet(mbuf, hdr_loc, _out_response_reason.data(), _out_response_reason.size());
519519
}

plugins/experimental/txn_box/plugin/src/ts_util.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ ts::HttpHeader::field_remove(swoc::TextView name)
660660
bool
661661
ts::HttpResponse::status_set(TSHttpStatus status) const
662662
{
663-
return TS_SUCCESS == TSHttpHdrStatusSet(_buff, _loc, status, nullptr, "");
663+
return TS_SUCCESS == TSHttpHdrStatusSet(_buff, _loc, status, "");
664664
}
665665

666666
TextView

plugins/experimental/wasm/ats_context.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1412,7 +1412,7 @@ Context::setProperty(std::string_view key, std::string_view serialized_value)
14121412

14131413
if (TSHttpTxnServerRespGet(txnp_, &bufp, &hdr_loc) == TS_SUCCESS) {
14141414
int64_t *status = reinterpret_cast<int64_t *>(const_cast<char *>(serialized_value.data()));
1415-
TSHttpHdrStatusSet(bufp, hdr_loc, static_cast<TSHttpStatus>(*status), txnp_, WASM_DEBUG_TAG);
1415+
TSHttpHdrStatusSet(bufp, hdr_loc, static_cast<TSHttpStatus>(*status), WASM_DEBUG_TAG);
14161416
TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
14171417
}
14181418
return WasmResult::Ok;

0 commit comments

Comments
 (0)