TSHTTPTXNSERVERREQGET(3ts)

πŸ“¦
version 9.2.5 Β· 4 versions
, in ubuntu noble, ubuntu questing

πŸ’– 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 that else branch? If it fails, mbuffer and mloc are 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. 😭

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