@@ -27,6 +27,9 @@ static zend_string *get_http_headers(php_stream *stream);
27
27
#define smart_str_append_const (str , const ) \
28
28
smart_str_appendl(str,const,sizeof(const)-1)
29
29
30
+ #define is_cstr_equals_literal_ci (str , len , literal ) \
31
+ ((len) == sizeof(literal)-1 && strncasecmp((str), "" literal, sizeof(literal)-1) == 0)
32
+
30
33
/* Proxy HTTP Authentication */
31
34
bool proxy_authentication (const zval * this_ptr , smart_str * soap_headers )
32
35
{
@@ -112,25 +115,16 @@ static void http_context_add_header(const char *s,
112
115
p ++ ;
113
116
}
114
117
/* 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
+ ) {
134
128
/* add header */
135
129
smart_str_appendl (soap_headers , s , p - s );
136
130
smart_str_append_const (soap_headers , "\r\n" );
0 commit comments