TSUrlStringGet

Traffic Server URL string representations API.

Synopsis

#include <ts/ts.h>

char * TSUrlStringGet(TSMBuffer bufp, TSMLoc offset, int * length)
char * TSHttpTxnEffectiveUrlStringGet(TSHttpTxn txn, int * length)
int TSUrlLengthGet(TSMBuffer bufp, TSMLoc offset)
void TSUrlPrint(TSMBuffer bufp, TSMLoc offset, TSIOBuffer iobufp)

Description

The URL data structure is a parsed version of a standard internet URL. The Traffic Server URL API provides access to URL data stored in marshal buffers. The URL functions can create, copy, retrieve or delete entire URLs, and retrieve or modify parts of URLs, such as their host, port or scheme information.

TSUrlStringGet() constructs a string representation of the URL located at offset within the marshal buffer bufp. TSUrlStringGet() stores the length of the allocated string in the parameter length. This is the same length that TSUrlLengthGet() returns. The returned string is allocated by a call to TSmalloc() and must be freed by a call to TSfree(). If length is NULL then no attempt is made to de-reference it.

TSHttpTxnEffectiveUrlStringGet() is similar to TSUrlStringGet(). The two differences are

  • The source is transaction txn in order to have access to the full request.
  • It combines, if needed, both the explicit url and the Host field. This is done if the explicit URL does not have a host and the Host field does.

This function is useful to guarantee a URL that is as complete as possible given the specific request.

TSUrlLengthGet() calculates the length of the URL located at offset within the marshal buffer bufp as if it were returned as a string. This length will be the same as the length returned by TSUrlStringGet().

TSUrlPrint() formats a URL stored in an TSMBuffer to an TSIOBuffer.

See Also

TSAPI(3ts), TSmalloc(3ts), TSUrlCreate(3ts), TSUrlHostGet(3ts), TSUrlHostSet(3ts), TSUrlPercentEncode(3ts)