Expose user-data-in-header functionality to Perl
Use length from main buffer, not tmp buffer