Skip to content

Commit da76b8f

Browse files
committed
BUG/MEDIUM: fix http-response sc-add-gpc and sc-inc-gpc
In http-response sc-add-gpc we were missing int and expression in the serialization http-response sc-inc-gpc was serialized as sc-add-gpc
1 parent 5ba56a3 commit da76b8f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

configuration/http_response_rule.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,15 +816,23 @@ func SerializeHTTPResponseRule(f models.HTTPResponseRule, opt *options.Configura
816816
}
817817
}
818818
case "sc-add-gpc":
819+
if len(f.ScExpr) > 0 && f.ScInt != nil {
820+
return nil, NewConfError(ErrValidationError, "sc-add-gpc int and expr are exclusive")
821+
}
822+
if len(f.ScExpr) == 0 && f.ScInt == nil {
823+
return nil, NewConfError(ErrValidationError, "sc-add-gpc int or expr has to be set")
824+
}
819825
rule = &actions.ScAddGpc{
820826
ID: strconv.FormatInt(f.ScID, 10),
821827
Idx: strconv.FormatInt(f.ScIdx, 10),
828+
Int: f.ScInt,
829+
Expr: common.Expression{Expr: strings.Split(f.ScExpr, " ")},
822830
Cond: f.Cond,
823831
CondTest: f.CondTest,
824832
Comment: comment,
825833
}
826834
case "sc-inc-gpc":
827-
rule = &actions.ScAddGpc{
835+
rule = &actions.ScIncGpc{
828836
ID: strconv.FormatInt(f.ScID, 10),
829837
Idx: strconv.FormatInt(f.ScIdx, 10),
830838
Cond: f.Cond,

0 commit comments

Comments
 (0)