.\" Man page generated from reStructuredText. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "TSURLSTRINGGET" "3ts" "Nov 02, 2023" "9.2" "Apache Traffic Server" .SH NAME TSUrlStringGet \- traffic Server URL string representations API .SH SYNOPSIS .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C #include .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .TP .B char *TSUrlStringGet(\fI\%TSMBuffer\fP bufp, \fI\%TSMLoc\fP offset, int *length) .UNINDENT .INDENT 0.0 .TP .B char *TSHttpTxnEffectiveUrlStringGet(\fI\%TSHttpTxn\fP txn, int *length) .UNINDENT .INDENT 0.0 .TP .B \fI\%TSReturnCode\fP TSHttpHdrEffectiveUrlBufGet(\fI\%TSMBuffer\fP hdr_buf, \fI\%TSMLoc\fP hdr_loc, char *buf, int64_t size, int64_t *length) .UNINDENT .INDENT 0.0 .TP .B int TSUrlLengthGet(\fI\%TSMBuffer\fP bufp, \fI\%TSMLoc\fP offset) .UNINDENT .INDENT 0.0 .TP .B void TSUrlPrint(\fI\%TSMBuffer\fP bufp, \fI\%TSMLoc\fP offset, \fI\%TSIOBuffer\fP iobufp) .UNINDENT .SH DESCRIPTION .sp 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. .sp \fI\%TSUrlStringGet()\fP constructs a string representation of the URL located at \fIoffset\fP within the marshal buffer \fIbufp\fP\&. (However \fIbufp\fP is actually superfluous and may be null.) \fI\%TSUrlStringGet()\fP stores the length of the allocated string in the parameter \fIlength\fP\&. This is the same length that \fI\%TSUrlLengthGet()\fP returns. The returned string is allocated by a call to \fI\%TSmalloc()\fP and must be freed by a call to \fI\%TSfree()\fP\&. If length is \fBNULL\fP then no attempt is made to de\-reference it. The returned string is not guaranteed to have a null terminator \- \fIlength\fP must be used to correctly display the string. .sp \fI\%TSHttpTxnEffectiveUrlStringGet()\fP is similar to \fI\%TSUrlStringGet()\fP\&. The two differences are: .INDENT 0.0 .IP \(bu 2 The source is transaction \fItxn\fP and the URL is retrieved from the client request in that transaction. .IP \(bu 2 If the client request URL has a host, that URL is returned, Otherwise, if there is a \(dqHost\(dq field the value of that field is used as the host in the returned URL. .UNINDENT .sp This function is useful to guarantee a URL that is as complete as possible given the specific request. .sp \fI\%TSHttpHdrEffectiveUrlBufGet()\fP returns the effective URL for any HTTP request (not just the client request). If the request has a Host header field (and the URL does not contain a host specifier), the host specifier the header provides is inserted into the URL. The host and scheme in the returned URL will be normalized to lower case letters (to make URL comparisons simple and fast). This prints the effective URL for the header specified by \fIhdr_buf\fP and \fIhdr_loc\fP to the buffer starting at \fIbuf\fP\&. If the effective URL is longer than \fIsize\fP, nothing is written to \fIbuf\fP\&. Note that this is not considered an error case, the function will still return \fITS_SUCCESS\fP\&. It is the responsibility of the caller to check this result to determine if output was generated. The full length of the URL is always returned in \fI*length\fP when the function returns \fITS_SUCCESS\fP\&. .sp The typical usage would be .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C TSMBuffer hdr_buf; TSMLoc hdr_loc; TSHttpTxnServerReqGet(txn, &hdr_buf, &hdr_loc); int64_t length; char store[2048]; char *buf = store; TSHttpHdrEffectiveUrlBufGet(hdr_buf, hdr_loc, buf, sizeof(store), &length); if (length > sizeof(store)) { buf = static_cast(malloc(length)); TSHttpHdrEffectiveUrlBufGet(hdr_buf, hdr_loc, buf, length, &length); } .ft P .fi .UNINDENT .UNINDENT .sp \fI\%TSUrlLengthGet()\fP calculates the length of the URL located at \fIoffset\fP within the marshal buffer bufp as if it were returned as a string. This length will be the same as the length returned by \fI\%TSUrlStringGet()\fP\&. .sp \fI\%TSUrlPrint()\fP formats a URL stored in an \fI\%TSMBuffer\fP to an \fI\%TSIOBuffer\fP\&. Capacity is added as needed to the \fIiobufp\fP to print the entire URL. .SH SEE ALSO .sp \fBTSAPI(3ts)\fP, \fBTSmalloc(3ts)\fP, \fBTSUrlCreate(3ts)\fP, \fBTSUrlHostGet(3ts)\fP, \fBTSUrlHostSet(3ts)\fP, \fBTSUrlPercentEncode(3ts)\fP .SH COPYRIGHT 2023, dev@trafficserver.apache.org .\" Generated by docutils manpage writer. .