MCPcopy Create free account
hub / github.com/apache/trafficserver / url_string_get_ref

Function url_string_get_ref

src/proxy/hdrs/URL.cc:620–652  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

618}
619
620char *
621url_string_get_ref(HdrHeap *heap, URLImpl *url, int *length, unsigned normalization_flags)
622{
623 if (!url) {
624 return nullptr;
625 }
626
627 if (url->m_ptr_printed_string && url->m_clean && (normalization_flags == url->m_normalization_flags)) {
628 if (length) {
629 *length = url->m_len_printed_string;
630 }
631 return const_cast<char *>(url->m_ptr_printed_string);
632 } else { // either not clean or never printed
633 int len = url_length_get(url, normalization_flags);
634 char *buf;
635 int index = 0;
636 int offset = 0;
637
638 /* stuff alloc'd here gets gc'd on HdrHeap::destroy() */
639 buf = heap->allocate_str(len + 1);
640 url_print(url, buf, len, &index, &offset, normalization_flags);
641 buf[len] = '\0';
642
643 if (length) {
644 *length = len;
645 }
646 url->m_clean = true; // reset since we have url_print()'ed again
647 url->m_len_printed_string = len;
648 url->m_ptr_printed_string = buf;
649 url->m_normalization_flags = normalization_flags;
650 return buf;
651 }
652}
653
654char *
655url_string_get(URLImpl *url, Arena *arena, int *length, HdrHeap *heap)

Callers 1

string_get_refMethod · 0.85

Calls 3

url_length_getFunction · 0.85
url_printFunction · 0.85
allocate_strMethod · 0.80

Tested by

no test coverage detected