Skip to content

Instantly share code, notes, and snippets.

@hostmaster
Last active December 11, 2015 02:19
Show Gist options
  • Save hostmaster/4529663 to your computer and use it in GitHub Desktop.
Save hostmaster/4529663 to your computer and use it in GitHub Desktop.
Adjust content length
length_field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, TS_MIME_FIELD_CONTENT_LENGTH, TS_MIME_LEN_CONTENT_LENGTH);
if (length_field_loc) {
content_length = TSMimeHdrFieldValueUintGet(bufp, hdr_loc, length_field_loc, 0);
TSDebug(DBG_TAG, "Content-Length was: %u", content_length);
new_content_length = content_length + delta;
TSMimeHdrFieldValuesClear(bufp, hdr_loc, length_field_loc);
TSMimeHdrFieldValueUintInsert(bufp, hdr_loc, length_field_loc, -1, new_content_length);
// check value
content_length = TSMimeHdrFieldValueUintGet(bufp, hdr_loc, length_field_loc, 0);
TSDebug(DBG_TAG, "Content-Length check: %u", content_length);
} else {
TSDebug(DBG_TAG, "Content-Length is not found");
}
ASSERT_SUCCESS(TSHandleMLocRelease(bufp, hdr_loc, length_field_loc));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment