import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new r1 = pcre2.regex("abc");
new r2 = pcre2.regex("a*bc");
new r3 = pcre2.regex("^abc");
new r4 = pcre2.regex("abc$");
new r5 = pcre2.regex("abc", anchored=true);
new r6 = pcre2.regex("(a|[^\d\n\rZ])");
new r7 = pcre2.regex("a|ba|\w");
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.first-1 = r1.info_str(FIRSTCODEUNIT);
set resp.http.firsts-1 = r1.info_str(FIRSTCODEUNITS);
set resp.http.last-1 = r1.info_str(LASTCODEUNIT);
set resp.http.first-2 = r2.info_str(FIRSTCODEUNIT);
set resp.http.firsts-2 = r2.info_str(FIRSTCODEUNITS);
set resp.http.last-2 = r2.info_str(LASTCODEUNIT);
set resp.http.first-3 = r3.info_str(FIRSTCODEUNIT);
set resp.http.firsts-3 = r3.info_str(FIRSTCODEUNITS);
set resp.http.last-3 = r3.info_str(LASTCODEUNIT);
set resp.http.first-4 = r4.info_str(FIRSTCODEUNIT);
set resp.http.firsts-4 = r4.info_str(FIRSTCODEUNITS);
set resp.http.last-4 = r4.info_str(LASTCODEUNIT);
set resp.http.first-5 = r5.info_str(FIRSTCODEUNIT);
set resp.http.firsts-5 = r5.info_str(FIRSTCODEUNITS);
set resp.http.last-5 = r5.info_str(LASTCODEUNIT);
set resp.http.first-6 = r6.info_str(FIRSTCODEUNIT);
set resp.http.firsts-6 = r6.info_str(FIRSTCODEUNITS);
set resp.http.last-6 = r6.info_str(LASTCODEUNIT);
set resp.http.first-7 = r7.info_str(FIRSTCODEUNIT);
set resp.http.firsts-7 = r7.info_str(FIRSTCODEUNITS);
set resp.http.last-7 = r7.info_str(LASTCODEUNIT);
set resp.http.firsts-stars-7
= r7.info_str(FIRSTCODEUNITS, sep="***");
return(deliver);
}
}
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.http.first-1 == "a"
expect resp.http.firsts-1 == ""
expect resp.http.last-1 == "c"
expect resp.http.first-2 == ""
expect resp.http.firsts-2 == "a b"
expect resp.http.last-2 == "c"
expect resp.http.first-3 == ""
expect resp.http.firsts-3 == ""
expect resp.http.last-3 == ""
expect resp.http.first-4 == "a"
expect resp.http.firsts-4 == ""
expect resp.http.last-4 == "c"
expect resp.http.first-5 == ""
expect resp.http.firsts-5 == ""
expect resp.http.last-5 == ""
expect resp.http.first-6 == ""
expect resp.http.firsts-6 == { ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ }
# "
expect resp.http.last-6 == ""
expect resp.http.first-7 == ""
expect resp.http.firsts-7 == "0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z _ a b c d e f g h i j k l m n o p q r s t u v w x y z"