| 2567 | } |
| 2568 | |
| 2569 | TSReturnCode |
| 2570 | TSHttpHdrCopy(TSMBuffer dest_bufp, TSMLoc dest_obj, TSMBuffer src_bufp, TSMLoc src_obj) |
| 2571 | { |
| 2572 | // Allow to modify the buffer only |
| 2573 | // if bufp is modifiable. If bufp is not modifiable return |
| 2574 | // TS_ERROR. If allowed, return TS_SUCCESS. Changed the |
| 2575 | // return value of function from void to TSReturnCode. |
| 2576 | sdk_assert(sdk_sanity_check_mbuffer(src_bufp) == TS_SUCCESS); |
| 2577 | sdk_assert(sdk_sanity_check_mbuffer(dest_bufp) == TS_SUCCESS); |
| 2578 | sdk_assert(sdk_sanity_check_http_hdr_handle(dest_obj) == TS_SUCCESS); |
| 2579 | sdk_assert(sdk_sanity_check_http_hdr_handle(src_obj) == TS_SUCCESS); |
| 2580 | |
| 2581 | if (!isWriteable(dest_bufp)) { |
| 2582 | return TS_ERROR; |
| 2583 | } |
| 2584 | |
| 2585 | bool inherit_strs; |
| 2586 | HdrHeap *s_heap, *d_heap; |
| 2587 | HTTPHdrImpl *s_hh, *d_hh; |
| 2588 | |
| 2589 | s_heap = (reinterpret_cast<HdrHeapSDKHandle *>(src_bufp))->m_heap; |
| 2590 | d_heap = (reinterpret_cast<HdrHeapSDKHandle *>(dest_bufp))->m_heap; |
| 2591 | s_hh = reinterpret_cast<HTTPHdrImpl *>(src_obj); |
| 2592 | d_hh = reinterpret_cast<HTTPHdrImpl *>(dest_obj); |
| 2593 | |
| 2594 | if ((s_hh->m_type != HDR_HEAP_OBJ_HTTP_HEADER) || (d_hh->m_type != HDR_HEAP_OBJ_HTTP_HEADER)) { |
| 2595 | return TS_ERROR; |
| 2596 | } |
| 2597 | |
| 2598 | inherit_strs = (s_heap != d_heap ? true : false); |
| 2599 | TSHttpHdrTypeSet(dest_bufp, dest_obj, static_cast<TSHttpType>(s_hh->m_polarity)); |
| 2600 | http_hdr_copy_onto(s_hh, s_heap, d_hh, d_heap, inherit_strs); |
| 2601 | return TS_SUCCESS; |
| 2602 | } |
| 2603 | |
| 2604 | void |
| 2605 | TSHttpHdrPrint(TSMBuffer bufp, TSMLoc obj, TSIOBuffer iobufp) |