/***
* @method task:has_header(name[, case_sensitive])
* Get decoded value of a header specified with optional case_sensitive flag.
- * By default headers are searched in caseless matter.
+ * By default headers are searched in the case insensitive matter.
* @param {string} name name of header to get
* @param {boolean} case_sensitive case sensitiveness flag to search for a header
- * @return {boolean},{number} true if header exists, the second value is number of headers with this name
+ * @return {boolean} true if header exists
*/
LUA_FUNCTION_DEF (task, has_header);
/***
if (rh == NULL) {
if (how == RSPAMD_TASK_HEADER_PUSH_HAS) {
lua_pushboolean (L, false);
- lua_pushnumber (L, 0);
- nret = 2;
+ nret = 1;
}
else if (how == RSPAMD_TASK_HEADER_PUSH_COUNT) {
lua_pushnumber (L, 0);
lua_pushinteger (L, i);
}
else if (how == RSPAMD_TASK_HEADER_PUSH_HAS) {
- i = 0;
- nret = 2;
-
- DL_FOREACH (rh, cur) {
- if (!strong || strcmp (name, cur->name) == 0) {
- i++;
+ nret = 1;
+ bool found = false;
+
+ if (strong) {
+ /* We still have to check all headers in the chain */
+ DL_FOREACH (rh, cur) {
+ if (strcmp (name, cur->name) == 0) {
+ found = true;
+ break;
+ }
}
}
+ else {
+ found = true;
+ }
- lua_pushboolean (L, true);
- lua_pushinteger (L, i);
+ lua_pushboolean (L, found);
}
else {
DL_FOREACH (rh, cur) {