| 5089 | } |
| 5090 | |
| 5091 | void |
| 5092 | HttpTransact::merge_warning_header(HTTPHdr *cached_header, HTTPHdr *response_header) |
| 5093 | { |
| 5094 | // The plan: |
| 5095 | // |
| 5096 | // 1) The cached header has it's warning codes untouched |
| 5097 | // since merge_response_header_with_cached_header() |
| 5098 | // doesn't deal with warning headers. |
| 5099 | // 2) If there are 1xx warning codes in the cached |
| 5100 | // header, they need to be removed. Removal |
| 5101 | // is difficult since the hdrs don't comma |
| 5102 | // separate values, so build up a new header |
| 5103 | // piecemeal. Very slow but shouldn't happen |
| 5104 | // very often |
| 5105 | // 3) Since we keep the all the warning codes from |
| 5106 | // the response header, append if to |
| 5107 | // the cached header |
| 5108 | // |
| 5109 | MIMEField *c_warn = cached_header->field_find(MIME_FIELD_WARNING, MIME_LEN_WARNING); |
| 5110 | MIMEField *r_warn = response_header->field_find(MIME_FIELD_WARNING, MIME_LEN_WARNING); |
| 5111 | MIMEField *new_cwarn = nullptr; |
| 5112 | int move_warn_len; |
| 5113 | const char *move_warn; |
| 5114 | |
| 5115 | // Loop over the cached warning header and transfer all non 1xx |
| 5116 | // warning values to a new header |
| 5117 | if (c_warn) { |
| 5118 | HdrCsvIter csv; |
| 5119 | |
| 5120 | move_warn = csv.get_first(c_warn, &move_warn_len); |
| 5121 | while (move_warn) { |
| 5122 | int code = ink_atoi(move_warn, move_warn_len); |
| 5123 | if (code < 100 || code > 199) { |
| 5124 | bool first_move; |
| 5125 | if (!new_cwarn) { |
| 5126 | new_cwarn = cached_header->field_create(); |
| 5127 | first_move = true; |
| 5128 | } else { |
| 5129 | first_move = false; |
| 5130 | } |
| 5131 | cached_header->field_value_append(new_cwarn, move_warn, move_warn_len, !first_move); |
| 5132 | } |
| 5133 | |
| 5134 | move_warn = csv.get_next(&move_warn_len); |
| 5135 | } |
| 5136 | |
| 5137 | // At this point we can nuke the old warning headers |
| 5138 | cached_header->field_delete(MIME_FIELD_WARNING, MIME_LEN_WARNING); |
| 5139 | |
| 5140 | // Add in the new header if it has anything in it |
| 5141 | if (new_cwarn) { |
| 5142 | new_cwarn->name_set(cached_header->m_heap, cached_header->m_mime, MIME_FIELD_WARNING, MIME_LEN_WARNING); |
| 5143 | cached_header->field_attach(new_cwarn); |
| 5144 | } |
| 5145 | } |
| 5146 | // Loop over all the dups in the response warning header and append |
| 5147 | // them one by one on to the cached warning header |
| 5148 | while (r_warn) { |
nothing calls this directly
no test coverage detected