mirror of
https://github.com/curl/curl.git
synced 2026-08-26 21:03:34 +03:00
tests: support hex encoded data and mqtt server
The mqtt server is started using a "random" port.
This commit is contained in:
parent
2522903b79
commit
675f5fb66f
4 changed files with 132 additions and 8 deletions
|
|
@ -35,6 +35,15 @@ sub decode_base64 {
|
|||
return unpack("u", $len . $_); # uudecode and print
|
||||
}
|
||||
|
||||
sub decode_hex {
|
||||
my $s = $_;
|
||||
# remove everything not hex
|
||||
$s =~ s/[^A-Fa-f0-9]//g;
|
||||
# encode everything
|
||||
$s =~ s/([a-fA-F0-9][a-fA-F0-9])/chr(hex($1))/eg;
|
||||
return $s;
|
||||
}
|
||||
|
||||
sub getpartattr {
|
||||
# if $part is undefined (ie only one argument) then
|
||||
# return the attributes of the section
|
||||
|
|
@ -81,6 +90,7 @@ sub getpart {
|
|||
my @this;
|
||||
my $inside=0;
|
||||
my $base64=0;
|
||||
my $hex=0;
|
||||
my $line;
|
||||
|
||||
for(@xml) {
|
||||
|
|
@ -96,6 +106,10 @@ sub getpart {
|
|||
# attempt to detect our base64 encoded part
|
||||
$base64=1;
|
||||
}
|
||||
elsif($_ =~ /$part [^>]*hex=/) {
|
||||
# attempt to detect a hex-encoded part
|
||||
$hex=1;
|
||||
}
|
||||
$inside++;
|
||||
}
|
||||
elsif(($inside >= 2) && ($_ =~ /^ *\<\/$part[ \>]/)) {
|
||||
|
|
@ -122,6 +136,13 @@ sub getpart {
|
|||
$_ = $decoded;
|
||||
}
|
||||
}
|
||||
elsif($hex) {
|
||||
# decode the whole array before returning it!
|
||||
for(@this) {
|
||||
my $decoded = decode_hex($_);
|
||||
$_ = $decoded;
|
||||
}
|
||||
}
|
||||
return @this;
|
||||
}
|
||||
elsif($inside >= 2) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue