+#if PHP_HTTP_CURL_VERSION(7,37,0)
+static ZEND_RESULT_CODE php_http_curle_option_set_proxyheader(php_http_option_t *opt, zval *val, void *userdata)
+{
+ php_http_client_curl_handler_t *curl = userdata;
+
+ if (val && Z_TYPE_P(val) != IS_NULL) {
+ php_http_arrkey_t header_key;
+ zval *header_val;
+ php_http_buffer_t header;
+
+ php_http_buffer_init(&header);
+ ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(val), header_key.h, header_key.key, header_val)
+ {
+ if (header_key.key) {
+ zend_string *zs = zval_get_string(header_val);
+ php_http_buffer_appendf(&header, "%s: %s", header_key.key->val, zs->val);
+ php_http_buffer_fix(&header);
+ curl->options.proxyheaders = curl_slist_append(curl->options.proxyheaders, header.data);
+ php_http_buffer_reset(&header);
+ zend_string_release(zs);
+ }
+ }
+ ZEND_HASH_FOREACH_END();
+ php_http_buffer_dtor(&header);
+ }
+ if (CURLE_OK != curl_easy_setopt(curl->handle, CURLOPT_PROXYHEADER, curl->options.proxyheaders)) {
+ return FAILURE;
+ }
+ if (CURLE_OK != curl_easy_setopt(curl->handle, CURLOPT_HEADEROPT, CURLHEADER_SEPARATE)) {
+ curl_easy_setopt(curl->handle, CURLOPT_PROXYHEADER, NULL);
+ return FAILURE;
+ }
+ return SUCCESS;
+}
+#endif
+