Skip to content

Commit bd6b61d

Browse files
committed
ext/soap/php_http.c: add is_cstr_equals_literal_ci() macro
1 parent a99a0ea commit bd6b61d

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

ext/soap/php_http.c

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ static zend_string *get_http_headers(php_stream *stream);
2727
#define smart_str_append_const(str, const) \
2828
smart_str_appendl(str,const,sizeof(const)-1)
2929

30+
#define is_cstr_equals_literal_ci(str, len, literal) \
31+
((len) == sizeof(literal)-1 && strncasecmp((str), "" literal, sizeof(literal)-1) == 0)
32+
3033
/* Proxy HTTP Authentication */
3134
bool proxy_authentication(const zval* this_ptr, smart_str* soap_headers)
3235
{
@@ -112,25 +115,16 @@ static void http_context_add_header(const char *s,
112115
p++;
113116
}
114117
/* skip some predefined headers */
115-
if ((name_len != sizeof("host")-1 ||
116-
strncasecmp(s, "host", sizeof("host")-1) != 0) &&
117-
(name_len != sizeof("connection")-1 ||
118-
strncasecmp(s, "connection", sizeof("connection")-1) != 0) &&
119-
(name_len != sizeof("user-agent")-1 ||
120-
strncasecmp(s, "user-agent", sizeof("user-agent")-1) != 0) &&
121-
(name_len != sizeof("content-length")-1 ||
122-
strncasecmp(s, "content-length", sizeof("content-length")-1) != 0) &&
123-
(name_len != sizeof("content-type")-1 ||
124-
strncasecmp(s, "content-type", sizeof("content-type")-1) != 0) &&
125-
(!has_cookies ||
126-
name_len != sizeof("cookie")-1 ||
127-
strncasecmp(s, "cookie", sizeof("cookie")-1) != 0) &&
128-
(!has_authorization ||
129-
name_len != sizeof("authorization")-1 ||
130-
strncasecmp(s, "authorization", sizeof("authorization")-1) != 0) &&
131-
(!has_proxy_authorization ||
132-
name_len != sizeof("proxy-authorization")-1 ||
133-
strncasecmp(s, "proxy-authorization", sizeof("proxy-authorization")-1) != 0)) {
118+
if (
119+
!is_cstr_equals_literal_ci(s, name_len, "host")
120+
&& !is_cstr_equals_literal_ci(s, name_len, "connection")
121+
&& !is_cstr_equals_literal_ci(s, name_len, "user-agent")
122+
&& !is_cstr_equals_literal_ci(s, name_len, "content-length")
123+
&& !is_cstr_equals_literal_ci(s, name_len, "content-type")
124+
&& (!has_cookies || !is_cstr_equals_literal_ci(s, name_len, "cookie"))
125+
&& (!has_authorization || !is_cstr_equals_literal_ci(s, name_len, "authorization"))
126+
&& (!has_proxy_authorization || !is_cstr_equals_literal_ci(s, name_len, "proxy-authorization"))
127+
) {
134128
/* add header */
135129
smart_str_appendl(soap_headers, s, p-s);
136130
smart_str_append_const(soap_headers, "\r\n");

0 commit comments

Comments
 (0)