| 1780 | } |
| 1781 | |
| 1782 | TSReturnCode |
| 1783 | TSMimeHdrFieldDestroy(TSMBuffer bufp, TSMLoc mh_mloc, TSMLoc field_mloc) |
| 1784 | { |
| 1785 | // Allow to modify the buffer only |
| 1786 | // if bufp is modifiable. If bufp is not modifiable return |
| 1787 | // TS_ERROR. If allowed, return TS_SUCCESS. Changed the |
| 1788 | // return value of function from void to TSReturnCode. |
| 1789 | sdk_assert(sdk_sanity_check_mbuffer(bufp) == TS_SUCCESS); |
| 1790 | sdk_assert((sdk_sanity_check_mime_hdr_handle(mh_mloc) == TS_SUCCESS) || |
| 1791 | (sdk_sanity_check_http_hdr_handle(mh_mloc) == TS_SUCCESS)); |
| 1792 | sdk_assert(sdk_sanity_check_field_handle(field_mloc, mh_mloc) == TS_SUCCESS); |
| 1793 | |
| 1794 | if (!isWriteable(bufp)) { |
| 1795 | return TS_ERROR; |
| 1796 | } |
| 1797 | |
| 1798 | MIMEFieldSDKHandle *field_handle = reinterpret_cast<MIMEFieldSDKHandle *>(field_mloc); |
| 1799 | |
| 1800 | if (field_handle->mh == nullptr) { // NOT SUPPORTED!! |
| 1801 | ink_release_assert(!"Failed MH"); |
| 1802 | } else { |
| 1803 | MIMEHdrImpl *mh = _hdr_mloc_to_mime_hdr_impl(mh_mloc); |
| 1804 | HdrHeap *heap = ((reinterpret_cast<HdrHeapSDKHandle *>(bufp))->m_heap); |
| 1805 | |
| 1806 | ink_assert(mh == field_handle->mh); |
| 1807 | if (sdk_sanity_check_field_handle(field_mloc, mh_mloc) != TS_SUCCESS) { |
| 1808 | return TS_ERROR; |
| 1809 | } |
| 1810 | |
| 1811 | // detach and delete this field, but not all dups |
| 1812 | mime_hdr_field_delete(heap, mh, field_handle->field_ptr, false); |
| 1813 | } |
| 1814 | // for consistence, the handle will not be released here. |
| 1815 | // users will be required to do it. |
| 1816 | return TS_SUCCESS; |
| 1817 | } |
| 1818 | |
| 1819 | TSReturnCode |
| 1820 | TSMimeHdrFieldCreate(TSMBuffer bufp, TSMLoc mh_mloc, TSMLoc *locp) |