# Functions

## `pvh_collect_headers()`

Collects all headers from the message into the XAVP. It should be used preferably just when the &sip; message is received by &kamailio;.

This function can be used from ANY_ROUTE.

## `pvh_apply_headers()`

Applies the current XAVP headers state to the real headers. Should be called only once per branch when the message is about to leave &kamailio;.

The following rules apply:

- all headers in the XAVP except for ones provided in the skip_headers parameter and From/To are recreated in the &sip; message.
- From/To headers are processed by the uac module if it is loaded.
- From/To headers are not changed in the reply messages.
- headers with NULL value are removed if exist in the &sip; message.
- the initial order of the &sip; headers is preserved.

This function can be used from ANY_ROUTE.

## `pvh_reset_headers()`

Collects all headers from the message into the XAVP. It should be used preferably just when the &sip; message is received by >&kamailio;.

This function can be used from ANY_ROUTE.

## `pvh_check_header(hname)`

Checks if the header hname already exists in the XAVP.

This function can be used from ANY_ROUTE but only after pvh_collect_headers() or with auto_msg parameter enabled.

## `pvh_append_header(hname, hvalue)`

Appends a new header hname with the value hvalue into the XAVP. Please note that subsequent "pv_append_header" calls will result in multiple headers.

If the provided hvalue is $null then the header is added into the XAVP but it is not going to be added into the message.

This function can be used from ANY_ROUTE but only after pvh_collect_headers() or with auto_msg parameter enabled.

## `pvh_modify_header(hname, hvalue, [idx])`

Modifies an existing header in the XAVP hname with the value hvalue into the XAVP. Index order is top to bottom. Please note that subsequent pvh_append_header calls will result in multiple headers.

Please note that if the header hnamedoes not exist it will be explicitly appended. If there are multiple headers with the same name and idx is omitted, only the first one will be affected.

This function can be used from ANY_ROUTE but only after pvh_collect_headers() or with auto_msg parameter enabled.

## `pvh_remove_header(hname, [idx])`

Removes an existing header hname from the XAVP. Index order is top to bottom.

If there are multiple headers with the same name and idx is omitted, all of them will be removed.

This function can be used from ANY_ROUTE but only after pvh_collect_headers() or with auto_msg parameter enabled.

## `pvh_remove_all_headers()`

Removes all sip message headers.

This function can be used from ANY_ROUTE but only after pvh_collect_headers() or with auto_msg parameter enabled.

## `pvh_header_param_exists(hname, hparameter)`

Checks if the parameter hparameter is present in the header hname from XAVP.

This function can be used from ANY_ROUTE but only after pvh_collect_headers() have been called or with auto_msg parameter enabled.

## `pvh_remove_header_param(hname, hparameter)`

Removes an existing parameter hparameter in the header hname from the XAVP.

If there are multiple headers, only the one containing the parameter will be modified.

The parameter can be located in any position (beginning, middle or end) of the list of parameters.

If the parameter is the only one present, the header will be removed.

This function can be used from ANY_ROUTE but only after pvh_collect_headers() have been called or with auto_msg parameter enabled.