]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REGTESTS: silence warnings about content-type being ignored
authorWilly Tarreau <w@1wt.eu>
Tue, 19 Nov 2024 06:59:21 +0000 (07:59 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 19 Nov 2024 07:06:26 +0000 (08:06 +0100)
The following rules are triggering warnings about content-type being
ignored:

  http-request return content-type "text/plain" if { path /def-4 }
  http-request return content-type "text/plain" file /dev/null hdr "x-custom-hdr" "%[url]"  if { path /empty-file }

Annoyingly, the content-type is mandatory when the file is not empty,
that might be something to revisit in the future to relax at least one
of the rules so that the config doesn't strictly require to know the
file contents upfront.

reg-tests/http-rules/http_return.vtc
reg-tests/sample_fetches/ubase64.vtc

index f292353cdc62910cea8b1756b713cf5413426f4b..ea4e95672e0a2295778089887e9c80bbb12d50ee 100644 (file)
@@ -22,11 +22,11 @@ haproxy h1 -conf {
         http-request return if { path /def-1 }
         http-request return hdr "x-custom-hdr" "%[url]" if { path /def-2 }
         http-request return status 403 if { path /def-3 }
-        http-request return content-type "text/plain" if { path /def-4 }
+        http-request return if { path /def-4 }
 
         http-request return content-type "text/plain" string "hello" hdr "x-custom-hdr" "%[url]"  if { path /string }
         http-request return content-type "text/plain" lf-string "path is %[url]" hdr "x-custom-hdr" "%[url]"  if { path /lf-string }
-        http-request return content-type "text/plain" file /dev/null hdr "x-custom-hdr" "%[url]"  if { path /empty-file }
+        http-request return                           file /dev/null hdr "x-custom-hdr" "%[url]"  if { path /empty-file }
         http-request return content-type "text/plain" file ${testdir}/1k.txt hdr "x-custom-hdr" "%[url]"  if { path /file }
         http-request return content-type "text/plain" lf-file ${testdir}/lf-file.txt hdr "x-custom-hdr" "%[url]"  if { path /lf-file }
 } -start
index 8e47d86d2250f25d6ecf0231d82fa95aa961c234..26fe02e820f55f4575cba728656d2004a6de797c 100644 (file)
@@ -20,9 +20,8 @@ haproxy h1 -conf {
     frontend fe
         bind "fd@${fe}"
                                acl input hdr(encode) -m found
-        http-request return content-type text/plain hdr encode %[hdr(encode),ub64enc] hdr decode %[hdr(decode),ub64dec] if input
-        http-request return content-type text/plain hdr encode %[bin(14fb9c03d97f12d97e),ub64enc] hdr decode %[str(FPucA9l_Etl-),ub64dec,hex,lower] if !input
-
+        http-request return hdr encode %[hdr(encode),ub64enc] hdr decode %[hdr(decode),ub64dec] if input
+        http-request return hdr encode %[bin(14fb9c03d97f12d97e),ub64enc] hdr decode %[str(FPucA9l_Etl-),ub64dec,hex,lower] if !input
 } -start
 
 client c1 -connect ${h1_fe_sock} {