### Description
We have some JS code looping over all P-Asserted-Identity headers removing some of the entries:
``` let headerIndex = 0; const telUriMatcher = new RegExp("tel:"); let paiValue = ksr.pv .gete("$(hdr(P-Asserted-Identity)[" + headerIndex + "])") .toString(); while (paiValue.length > 0) { ksr.info( `${ksr.pv.getw("$ci")}: Found P-A-I header with content <${ksr.pv.getw( "$(hdr(P-Asserted-Identity)[" + headerIndex + "])" )}> at index ${headerIndex}\n` ); if (telUriMatcher.test(paiValue)) { ksr.info( `${ksr.pv.getw("$ci")}: Removed P-A-I header ${ksr.pv.getw( "$(hdr(P-Asserted-Identity)[" + headerIndex + "])" )}\n` ); ksr.textopsx.remove_hf_value( "P-Asserted-Identity[" + headerIndex + "]" ); } headerIndex++; paiValue = ksr.pv .gete("$(hdr(P-Asserted-Identity)[" + headerIndex + "])") .toString(); } ``` In our tests, we wanted to remove the second header, but the first one got removed instead. The pseudovars docs say, the index of a header is 0-based. In textopsx docs it doesn't explicitly say, it's 1-based, but the first example shows it actually is.
### Possible Solutions
Right now, we replaced the line ``` ksr.textopsx.remove_hf_value("P-Asserted-Identity[" + headerIndex + "]"); ``` with this one: ``` ksr.textopsx.remove_hf_value("P-Asserted-Identity[" + (headerIndex + 1) + "]"); ``` This solves the problem, but it is not what we would expect. Both header access methods should use the same index base.
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
``` version: kamailio 5.3.5 (x86_64/linux) flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB poll method support: poll, epoll_lt, epoll_et, sigio_rt, select. id: unknown compiled with gcc 8.3.0 ```
* **Operating System**:
<!-- Details about the operating system, the type: Linux (e.g.,: Debian 8.4, Ubuntu 16.04, CentOS 7.1, ...), MacOS, xBSD, Solaris, ...; Kernel details (output of `uname -a`) -->
``` Linux hostname 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1 (2020-06-07) x86_64 GNU/Linux ```
The textopsx functions were developed by the SER project devs, when there were two separate projects, so it could be that they used 1-based index. If not clear in documentation, then it should be added there for now.
Otherwise, I am fine to get it use 0-based indexing, to be more coherent across the modules.
Added explicit notes about 1-based index in textopsx docs.
Closed #2387.