| 3945 | } |
| 3946 | |
| 3947 | TSReturnCode |
| 3948 | TSHttpHdrEffectiveUrlBufGet(TSMBuffer hdr_buf, TSMLoc hdr_loc, char *buf, int64_t size, int64_t *length) |
| 3949 | { |
| 3950 | sdk_assert(sdk_sanity_check_mbuffer(hdr_buf) == TS_SUCCESS); |
| 3951 | sdk_assert(sdk_sanity_check_http_hdr_handle(hdr_loc) == TS_SUCCESS); |
| 3952 | if (size) { |
| 3953 | sdk_assert(sdk_sanity_check_null_ptr(buf) == TS_SUCCESS); |
| 3954 | } |
| 3955 | sdk_assert(sdk_sanity_check_null_ptr(length) == TS_SUCCESS); |
| 3956 | |
| 3957 | auto buf_handle = reinterpret_cast<HTTPHdr *>(hdr_buf); |
| 3958 | auto hdr_handle = reinterpret_cast<HTTPHdrImpl *>(hdr_loc); |
| 3959 | |
| 3960 | if (hdr_handle->m_polarity != HTTP_TYPE_REQUEST) { |
| 3961 | Dbg(dbg_ctl_plugin, "Trying to get a URL from response header %p", hdr_loc); |
| 3962 | return TS_ERROR; |
| 3963 | } |
| 3964 | |
| 3965 | int url_length = buf_handle->url_printed_length(URLNormalize::LC_SCHEME_HOST | URLNormalize::IMPLIED_SCHEME); |
| 3966 | |
| 3967 | sdk_assert(url_length >= 0); |
| 3968 | |
| 3969 | *length = url_length; |
| 3970 | |
| 3971 | // If the user-provided buffer is too small to hold the URL string, do not put anything in it. This is not considered |
| 3972 | // an error case. |
| 3973 | // |
| 3974 | if (url_length <= size) { |
| 3975 | int index = 0; |
| 3976 | int offset = 0; |
| 3977 | |
| 3978 | buf_handle->url_print(buf, size, &index, &offset, URLNormalize::LC_SCHEME_HOST | URLNormalize::IMPLIED_SCHEME); |
| 3979 | } |
| 3980 | |
| 3981 | return TS_SUCCESS; |
| 3982 | } |
| 3983 | |
| 3984 | TSReturnCode |
| 3985 | TSHttpTxnClientRespGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLoc *obj) |