Browse code

pv: added $msg(lpart) - return last part of the message

- headers and body (skips first line)

Daniel-Constantin Mierla authored on 08/12/2021 14:16:12
Showing 1 changed files
... ...
@@ -4114,6 +4114,8 @@ int pv_parse_msg_attrs_name(pv_spec_p sp, str *in)
4114 4114
 				sp->pvp.pvn.u.isname.name.n = 4;
4115 4115
 			else if(strncmp(in->s, "fpart", 5)==0)
4116 4116
 				sp->pvp.pvn.u.isname.name.n = 7;
4117
+			else if(strncmp(in->s, "lpart", 5)==0)
4118
+				sp->pvp.pvn.u.isname.name.n = 9;
4117 4119
 			else goto error;
4118 4120
 		break;
4119 4121
 		case 8:
... ...
@@ -4210,6 +4212,12 @@ int pv_get_msg_attrs(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
4210 4212
 			s.len = msg->unparsed - s.s;
4211 4213
 			trim(&s);
4212 4214
 			return pv_get_sintval(msg, param, res, s.len);
4215
+		case 9: /* last part - headers + body */
4216
+			if(msg->headers==NULL || msg->headers->name.s==NULL)
4217
+				return pv_get_null(msg, param, res);
4218
+			s.s = msg->headers->name.s;
4219
+			s.len = msg->buf + msg->len - s.s;
4220
+			return pv_get_strval(msg, param, res, &s);
4213 4221
 
4214 4222
 		default:
4215 4223
 			return pv_get_null(msg, param, res);