Miroslav,

On 9/10/21 8:08 PM, Miroslav Zagorac wrote:
the problem is that in this case after calling the function
htx_get_blk_value(), v.ptr is not a NULL pointer but v.len is equal
to 0, if the http header has no value.


If it's not a NULL pointer then it must be a valid pointer. I don't quite understand why you would need to replace this by an empty constant string then? Is this about a missing NUL terminator? Otherwise a valid pointer with .len == 0 would be equivalent to "".

-----

Unrelated to that: Having worked quite a bit with the ist API I would generally recommend using the helper functions in ist.h (possibly adding new ones if they are helpful) instead of directly touching the struct. It makes refactoring much easier, because it's easy to find the function calls vs. accessing struct members which might be available on different structs.

As an example in flt_ot_http_headers_get you could use an ist for prefix and then simply use isteqi() instead of strncasecmp().

> Of course, it could look like this:
>
> if (v.len == 0)
>      v.ptr = "" /* or v = ist("") */;
>

In your example I would prefer v = ist("") over v.ptr = "" and leave the heavy lifting up to the compiler for that reason.

Best regards
Tim Düsterhus

Reply via email to