NAME¶
TSMBufferCreate - traffic Server marshall buffer API
SYNOPSIS¶
#include <ts/ts.h>
- TSMBuffer TSMBufferCreate(void)
- TSReturnCode TSMBufferDestroy(TSMBuffer bufp)
- TSReturnCode TSHandleMLocRelease(TSMBuffer bufp,
TSMLoc parent, TSMLoc mloc)
DESCRIPTION¶
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
TSHttpTxn*Get() 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.
RETURN VALUES¶
TSMBufferDestroy() and
TSHandleMLocRelease() return
TS_SUCCESS on success, or
TS_ERROR on failure.
TSMBufferCreate() returns the new
TSMBuffer.
EXAMPLES¶
#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);
}
SEE ALSO¶
TSAPI(3ts)
COPYRIGHT¶
2015, dev@trafficserver.apache.org