TSMIMEHDRFIELDCREATE(3ts)

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

πŸ’– TSMIMEHDRFIELDCREATE πŸ’–

okay bestie so this is a page from the 3ts manual, and it's all about the Apache Traffic Server life. we're making MIME header fields today. it's giving header-crafting main character energy and honestly? obsessed. πŸŽ€


✨ NAME ✨

TSMimeHdrFieldCreate β€” the TSMimeHdrFieldCreate API function, obviously πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <ts/ts.h>

TSReturnCode TSMimeHdrFieldCreate(TSMBuffer bufp, TSMLoc hdr, TSMLoc *out)

TSReturnCode TSMimeHdrFieldCreateNamed(TSMBuffer bufp, TSMLoc hdr, const
char *name, int name_len, TSMLoc *out)

like yes, two functions, both iconic, both returning TSReturnCode. we love a duo. πŸ‘‘


🌸 DESCRIPTION 🌸

so these functions literally create MIME fields inside a MIME header. the header you're working with is specified by the combination of the buffer bufp and a location hdr. and ngl, that header has to come from somewhere legit β€” either it was created, like with TSMimeHdrCreate(), or it's an existing header you found through a function like TSHttpTxnClientReqGet(). no making up headers out of thin air, bestie. πŸ’€

TSMimeHdrFieldCreate() makes a completely empty field, which means it must be named before it can be used in a header β€” usually you'd do that with TSMimeHdrFieldNameSet(). it's a two-step situation. valid, but extra.

which is why, fr fr, it's almost always more convenient to use TSMimeHdrFieldCreateNamed(), because that one combines those two steps for you β€” it creates the field and then sets the name to name. one and done, slay. ✨

for both functions, a reference to the new field gets handed back to you via out. 🫢

now here's the important tea: the field you just created is not in a header, even though it lives in the same buffer. it's like... adjacent, not attached. if you want it in a header you gotta add it yourself with TSMimeHdrFieldAppend(). πŸ’…

also the field has no value, only a name. that's it. that's the whole field. if you need a value you have to add it explicitly with a function like TSMimeHdrFieldValueIntSet(). no value materializes on its own, no cap. πŸ¦‹

⚠️ lowkey the biggest thing to remember: create β‰  append, and name β‰  value. those are separate steps and the API will not do them for you. periodt.

Copyright 2026, dev@trafficserver.apache.org πŸ“


and that's the whole page bestie!! 🧚 this was Apache Traffic Server 9.2, dated Feb 12, 2026, brought to you by the lovely humans at dev@trafficserver.apache.org. go forth and create fields responsibly. mwah πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from