| 87 | } |
| 88 | |
| 89 | void |
| 90 | form416HeaderAndBody(HttpHeader &header, int64_t const contentlen, std::string const &bodystr) |
| 91 | { |
| 92 | header.removeKey(TS_MIME_FIELD_LAST_MODIFIED, TS_MIME_LEN_LAST_MODIFIED); |
| 93 | header.removeKey(TS_MIME_FIELD_EXPIRES, TS_MIME_LEN_EXPIRES); |
| 94 | header.removeKey(TS_MIME_FIELD_ETAG, TS_MIME_LEN_ETAG); |
| 95 | header.removeKey(TS_MIME_FIELD_ACCEPT_RANGES, TS_MIME_LEN_ACCEPT_RANGES); |
| 96 | |
| 97 | header.setStatus(TS_HTTP_STATUS_REQUESTED_RANGE_NOT_SATISFIABLE); |
| 98 | char const *const reason = TSHttpHdrReasonLookup(TS_HTTP_STATUS_REQUESTED_RANGE_NOT_SATISFIABLE); |
| 99 | header.setReason(reason, strlen(reason)); |
| 100 | |
| 101 | char bufstr[256]; |
| 102 | int buflen = snprintf(bufstr, sizeof(bufstr), "%lu", bodystr.size()); |
| 103 | header.setKeyVal(TS_MIME_FIELD_CONTENT_LENGTH, TS_MIME_LEN_CONTENT_LENGTH, bufstr, buflen); |
| 104 | |
| 105 | static char const *const ctypestr = "text/html"; |
| 106 | static int const ctypelen = strlen(ctypestr); |
| 107 | header.setKeyVal(TS_MIME_FIELD_CONTENT_TYPE, TS_MIME_LEN_CONTENT_TYPE, ctypestr, ctypelen); |
| 108 | |
| 109 | buflen = snprintf(bufstr, 255, "*/%" PRId64, contentlen); |
| 110 | header.setKeyVal(TS_MIME_FIELD_CONTENT_RANGE, TS_MIME_LEN_CONTENT_RANGE, bufstr, buflen); |
| 111 | } |
no test coverage detected