Browse code

pv_headers: pvh_set_header, remove values to set null when necessary

* fix pvh_set_xavi for SR_XTYPE_NULL

(cherry picked from commit af926514ac3e70dff51408baf326b29bce4eecfc)

Victor Seva authored on 27/07/2021 08:52:21
Showing 1 changed files
... ...
@@ -375,7 +375,7 @@ int pvh_set_xavi(struct sip_msg *msg, str *xname, str *name, void *data,
375 375
 	LM_DBG("br_xname: %.*s name: %.*s append:%d\n", br_xname.len, br_xname.s,
376 376
 			name->len, name->s, append);
377 377
 	memset(&xval, 0, sizeof(sr_xval_t));
378
-	if(data == NULL || SR_XTYPE_NULL) {
378
+	if(data == NULL || type == SR_XTYPE_NULL) {
379 379
 		xval.type = SR_XTYPE_NULL;
380 380
 	} else if(type == SR_XTYPE_STR) {
381 381
 		xval.type = SR_XTYPE_STR;
... ...
@@ -618,9 +618,11 @@ int pvh_set_header(
618 618
 
619 619
 	if(val == NULL || (val->flags & PV_VAL_NULL)) {
620 620
 		if(idxf == PV_IDX_ALL) {
621
-			cnt = xavi_rm_by_name(hname, 1, &avi);
622
-			LM_DBG("removed %d values of %.*s=>%.*s, set $null\n", cnt,
623
-					xavi->name.len, xavi->name.s, hname->len, hname->s);
621
+			if(hname_cnt > 1) {
622
+				cnt = xavi_rm_by_name(hname, 1, &avi);
623
+				LM_DBG("removed %d values of %.*s=>%.*s, set $null\n", cnt,
624
+						xavi->name.len, xavi->name.s, hname->len, hname->s);
625
+			}
624 626
 			if(pvh_set_xavi(msg, &xavi_name, hname, NULL, SR_XTYPE_NULL, 0, 0)
625 627
 					< 0)
626 628
 				goto err;