TSHTTPTXNSERVERREQGET(3ts)
π NAME π
TSHttpTxnServerReqGet β bestie, this is the TSHttpTxnServerReqGet API function, and it's literally the glow-up your plugin needs to peek at the request Traffic Server is yeeting upstream. π¦
β¨ SYNOPSIS β¨
#include <ts/ts.h>
TSReturnCode TSHttpTxnServerReqGet(TSHttpTxn txnp, TSMBuffer *bufp,
TSMLoc *obj)
π DESCRIPTION π
Okay so here's the tea, bestie: this grabs the request Traffic Server is sending to the upstream (server) for the transaction txnp. And bufp and obj? Those need to be valid pointers that you're handing over so they can be used as return values. Like, they're the little empty cups you're passing in and the function fills them up. π«Ά
Your call site could look something like this:
TSMBuffer mbuffer;
TSMLoc mloc;
if (TS_SUCCESS == TSHttpTxnServerReqGet(&mbuffer, &mloc)) {
/* Can use safely mbuffer, mloc for subsequent API calls */
} else {
/* mbuffer, mloc in an undefined state */
}
β οΈ Okay but real talk: notice thatelsebranch? If it fails,mbufferandmlocare in an undefined state. Do not touch them. Do not look at them. Do not pass go. π
This call returns TS_SUCCESS on success, and TS_ERROR on failure. And it is the caller's responsibility to make sure that txnp is a valid transaction β so like, that's on you, bestie, nobody's gonna check it for you. π
Once you've got the request object, it's giving β¨main character energyβ¨ β you can use it to access all of the elements of the request, such as the URL, the header fields, etc. Obsessed. π
And plot twist, this is also the mechanism by which a plugin can change the upstream request β if it's done before the request is sent (in or before TS_HTTP_SEND_REQUEST_HDR_HOOK). Slay.
πΈ Careful though: for earlier hooks, the request may not yet exist, in which case an error is returned. Like, you showed up to the party before the party even started. No cap. π
π COPYRIGHT π
2026, dev@trafficserver.apache.org
And that's a wrap on the whole vibe, fr fr. This lil' baddie comes to you from Apache Traffic Server 9.2, dated Feb 12, 2026. Go forth and get those upstream requests, bestie β periodt. πβ¨ππ¦πΈπ π«Ά
π¦ where this page comes from
- ubuntu noble: trafficserver-dev 9.2.3+ds-1+deb12u1ubuntu0.1 Β· Apache-2.0
- ubuntu questing: trafficserver-dev 9.2.5+ds-1ubuntu2.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms