TSMIMEHDRFIELDCREATE(3ts)
π 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 π
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
- 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