| 2534 | } |
| 2535 | |
| 2536 | TSReturnCode |
| 2537 | TSHttpHdrClone(TSMBuffer dest_bufp, TSMBuffer src_bufp, TSMLoc src_hdr, TSMLoc *locp) |
| 2538 | { |
| 2539 | // Allow to modify the buffer only |
| 2540 | // if bufp is modifiable. If bufp is not modifiable return |
| 2541 | // TS_ERROR. If not allowed, set *locp to TS_NULL_MLOC. |
| 2542 | sdk_assert(sdk_sanity_check_mbuffer(dest_bufp) == TS_SUCCESS); |
| 2543 | sdk_assert(sdk_sanity_check_mbuffer(src_bufp) == TS_SUCCESS); |
| 2544 | sdk_assert(sdk_sanity_check_http_hdr_handle(src_hdr) == TS_SUCCESS); |
| 2545 | |
| 2546 | if (!isWriteable(dest_bufp)) { |
| 2547 | return TS_ERROR; |
| 2548 | } |
| 2549 | |
| 2550 | HdrHeap *s_heap, *d_heap; |
| 2551 | HTTPHdrImpl *s_hh, *d_hh; |
| 2552 | |
| 2553 | s_heap = (reinterpret_cast<HdrHeapSDKHandle *>(src_bufp))->m_heap; |
| 2554 | d_heap = (reinterpret_cast<HdrHeapSDKHandle *>(dest_bufp))->m_heap; |
| 2555 | s_hh = reinterpret_cast<HTTPHdrImpl *>(src_hdr); |
| 2556 | |
| 2557 | if (s_hh->m_type != HDR_HEAP_OBJ_HTTP_HEADER) { |
| 2558 | return TS_ERROR; |
| 2559 | } |
| 2560 | |
| 2561 | // TODO: This is never used |
| 2562 | // inherit_strs = (s_heap != d_heap ? true : false); |
| 2563 | d_hh = http_hdr_clone(s_hh, s_heap, d_heap); |
| 2564 | *locp = reinterpret_cast<TSMLoc>(d_hh); |
| 2565 | |
| 2566 | return TS_SUCCESS; |
| 2567 | } |
| 2568 | |
| 2569 | TSReturnCode |
| 2570 | TSHttpHdrCopy(TSMBuffer dest_bufp, TSMLoc dest_obj, TSMBuffer src_bufp, TSMLoc src_obj) |