NAME

Uniform::Utils - Shared production-grade utility functions for Uniform ecosystem authors

FUNCTIONS

normalize_http_headers( \%raw_hash )

Accepts a raw hash reference of incoming network parameters and transforms them into a clean, normalized data model based on strict ecosystem validation criteria:

  • Case Insensitivity: All incoming keys are lowercased and bounding whitespace is stripped.

  • Environment Pruning: CGI/PSGI HTTP_ and HTTP- environment prefixes are safely removed.

  • Priority Ranking: Real HTTP header definitions cleanly take precedence over environment-variable duplicates.

  • Array Reduction: Duplicate incoming headers packed into array references are automatically reduced down to the last scalar definition.

  • Security Sandboxing: Keys failing structural validation checks are rejected entirely, filtering out malicious header manipulation or collision vectors.

parse_size_limit( $limit )

Converts a human-readable size string into a plain byte count. $limit may be a number of bytes on its own, or a number followed by a K, M, or G suffix (case-insensitive, 1024-based: kilobytes, megabytes, gigabytes) -- e.g. '500K', '2M', '1G', or a bare '2048'.

Throws a ValidationError via Uniform::Exceptions if $limit is undefined, an empty string, or does not match a parsable size expression. Returns the equivalent byte count as a plain number on success.

use Uniform::Utils qw(parse_size_limit);

my $bytes = parse_size_limit('2M'); # 2097152