Subject: | Can't send header values that match /\d+/, breaks big application |
I'm trying to send an AMQP header that looks like:
'X-My-Header' => '12345123451234512345'
but Net::AMQP mangles it, thusly:
sub _pack_field_value {
my ($value) = @_;
if (not ref $value) {
if ($value =~ /^\d+\z/) {
# Unsigned int
'I' . pack_long_integer($value)
} else {
# FIXME - assuming that all other values are string values
'S' . pack_long_string($value)
}
}
...
The number doesn't fit in a long integer, and anyway it isn't an
integer, it's a string that happens to be made up of digits.
At the *very* least, please use long_long_integer when the number can't
fit into a long_integer. May as well use short integers when possible,
too, since you have to check for such things anyway.
Next after that, allow callers to specify some way to control the
encoding of fields. Allow me to pass Net::AMQP::Integer->($x) or
Net::AMQP::String->($x).
Finally, to allow full and automatic correctness, find a CPAN module or
write some XS code that can detect the difference between 123 and "123".
It isn't hard; just look for SvNOIK() on the one hand, and SvPOK() on
the other. Which way you default when both or neither is true is
unimportant.