DOKK / manpages / debian 12 / trafficserver-dev / TSMBufferCreate.3ts.en
TSMBUFFERCREATE(3ts) Apache Traffic Server TSMBUFFERCREATE(3ts)

TSMBufferCreate - traffic Server marshall buffer API

#include <ts/ts.h>





The marshal buffer or TSMBuffer is a heap data structure that stores parsed URLs, MIME headers and HTTP headers. You can allocate new objects out of marshal buffers, and change the values within the marshal buffer. Whenever you manipulate an object, you require the handle to the object (TSMLoc) and the marshal buffer containing the object (TSMBuffer).

Any marshal buffer fetched by transaction getters will be used by other parts of the system. Be careful not to destroy these shared, transaction marshal buffers.

TSMBufferCreate() creates a new marshal buffer and initializes the reference count. TSMBufferDestroy() Ignores the reference count and destroys the marshal buffer bufp. The internal data buffer associated with the marshal buffer is also destroyed if the marshal buffer allocated it.

TSHandleMLocRelease() Releases the TSMLoc mloc created from the TSMLoc parent. If a TSMLoc is obtained from a transaction, it does not have a parent TSMLoc. Use the the constant TS_NULL_MLOC as its parent.

TSMBufferDestroy() and TSHandleMLocRelease() return TS_SUCCESS on success, or TS_ERROR on failure. TSMBufferCreate() returns the new TSMBuffer.

#include <ts/ts.h>
static void
copyResponseMimeHdr (TSCont pCont, TSHttpTxn pTxn)
{

TSMBuffer respHdrBuf, tmpBuf;
TSMLoc respHttpHdrLoc, tmpMimeHdrLoc;
if (!TSHttpTxnClientRespGet(pTxn, &respHdrBuf, &respHttpHdrLoc)) {
TSError("couldn't retrieve client response header0);
TSHandleMLocRelease(respHdrBuf, TS_NULL_MLOC, respHttpHdrLoc);
goto done;
}
tmpBuf = TSMBufferCreate();
tmpMimeHdrLoc = TSMimeHdrCreate(tmpBuf);
TSMimeHdrCopy(tmpBuf, tmpMimeHdrLoc, respHdrBuf, respHttpHdrLoc);
TSHandleMLocRelease(tmpBuf, TS_NULL_MLOC, tmpMimeHdrLoc);
TSHandleMLocRelease(respHdrBuf, TS_NULL_MLOC, respHttpHdrLoc);
TSMBufferDestroy(tmpBuf); done:
TSHttpTxnReenable(pTxn, TS_EVENT_HTTP_CONTINUE); }


TSAPI(3ts)

2023, dev@trafficserver.apache.org

November 2, 2023 9.2