TSURLHOSTSET(3ts)

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

πŸ’– TSURLHOSTSET β€” the URL-glow-up page (3ts) πŸ’–

okay bestie, welcome to tsurlhostset, aka the part of the Apache Traffic Server manual where we learn how to set pieces of a URL instead of just staring at them. this is the Traffic Server URL component manipulation API and honestly? it's giving backstage-pass energy. you get to reach into a URL and change its little outfit piece by piece. slay. πŸŽ€


✨ SYNOPSIS ✨

first things first, you gotta bring the header in like a little VIP:

#include <ts/ts.h>

then here's the whole squad of setters, all lined up and ready:

TSReturnCode TSUrlHostSet(TSMBuffer bufp, TSMLoc offset, const char
*value, int length)

TSReturnCode TSUrlSchemeSet(TSMBuffer bufp, TSMLoc offset, const char
*value, int length)

TSReturnCode TSUrlUserSet(TSMBuffer bufp, TSMLoc offset, const char
*value, int length)

TSReturnCode TSUrlPasswordSet(TSMBuffer bufp, TSMLoc offset, const char
*value, int length)

TSReturnCode TSUrlPortSet(TSMBuffer bufp, TSMLoc offset, int port)

TSReturnCode TSUrlPathSet(TSMBuffer bufp, TSMLoc offset, const char
*value, int length)

TSReturnCode TSUrlHttpQuerySet(TSMBuffer bufp, TSMLoc offset, const char
*value, int length)

TSReturnCode TSUrlHttpParamsSet(TSMBuffer bufp, TSMLoc offset, const
char *value, int length)

TSReturnCode TSUrlHttpFragmentSet(TSMBuffer bufp, TSMLoc offset, const
char *value, int length)

look at them. nine little icons. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so. the URL data structure is literally just a parsed version of a standard internet URL β€” like the URL went to the salon and came out with all its parts separated and labeled. the Traffic Server URL API gives you access to URL data stored in marshal buffers. the URL functions can create, copy, retrieve or delete entire URLs, and they can also retrieve or modify parts of URLs β€” stuff like their host, port or scheme info. pick your fighter. πŸ’–

now, the main character lineup:

TSUrlSchemeSet(), TSUrlUserSet(), TSUrlPasswordSet(), TSUrlHostSet(), TSUrlHttpParamsSet(), TSUrlHttpQuerySet() and TSUrlHttpFragmentSet() each set the specified portion of the URL located at offset within the marshal buffer bufp to the string value.

and here's the little detail that trips people up, so listen up bestie:

  • if length is -1, then these functions assume that value is NULL-terminated.
  • otherwise, the length of the string value is taken to be the value of length.

these functions copy the string to within bufp, so it can be subsequently modified or deleted. no borrowed references, no weird lingering drama β€” it's a whole new copy, periodt. 🫢

then we have TSUrlPortSet(), which is the odd one out and honestly kind of iconic for it. it sets the port number portion of the URL located at offset within the marshal buffer bufp to the value port. notice there's no length here β€” port is an int, not a string. and also: normal canonicalization based on the URL scheme still applies. so don't think you can just yeet a weird port in there and escape the rules. the scheme said what it said. πŸ’€


🌸 RETURN VALUES 🌸

all these APIs return a TSReturnCode, indicating success (TS_SUCCESS) or failure (TS_ERROR) of the operation.

that's it. that's the whole vibe check. TS_SUCCESS = ate. TS_ERROR = did not eat, pls check ur inputs. ✨


🧚 SEE ALSO 🧚

go be nosy, these are the friends:


2026, dev@trafficserver.apache.org


and that's the page, bestie!! 🌈 this was Apache Traffic Server 9.2, dated Feb 12, 2026 β€” so like, the copyright says 2026, dev@trafficserver.apache.org and the version is 9.2, and yes i'm telling you again bc the footer deserves its moment. go forth and set some URL components. you're literally the main character of this marshal buffer. πŸ’œπŸ¦‹βœ¨

πŸ“¦ where this page comes from