| 30 | #include "tsutil/LocalBuffer.h" |
| 31 | |
| 32 | int |
| 33 | VersionConverter::convert(HTTPHdr &header, int from, int to) const |
| 34 | { |
| 35 | int type = 0; |
| 36 | |
| 37 | switch (http_hdr_type_get(header.m_http)) { |
| 38 | case HTTP_TYPE_REQUEST: |
| 39 | type = 0; |
| 40 | break; |
| 41 | case HTTP_TYPE_RESPONSE: |
| 42 | type = 1; |
| 43 | break; |
| 44 | case HTTP_TYPE_UNKNOWN: |
| 45 | ink_abort("HTTP_TYPE_UNKNOWN"); |
| 46 | break; |
| 47 | } |
| 48 | |
| 49 | ink_assert(MIN_VERSION <= from && from <= MAX_VERSION); |
| 50 | ink_assert(MIN_VERSION <= to && to <= MAX_VERSION); |
| 51 | |
| 52 | int ret = (this->*_convert_functions[type][from - 1][to - 1])(header); |
| 53 | if (ret < 0) { |
| 54 | return -1; |
| 55 | } |
| 56 | |
| 57 | // Check validity of all names and values |
| 58 | for (auto &&mf : header) { |
| 59 | if (!mf.name_is_valid(is_control_BIT | is_ws_BIT) || !mf.value_is_valid()) { |
| 60 | return -1; |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | return 0; |
| 65 | } |
| 66 | |
| 67 | int |
| 68 | VersionConverter::_convert_nop(HTTPHdr & /* header ATS_UNUSED */) const |
no test coverage detected