remove cookies from transfer-info
[m6w6/ext-http] / php_http_client_curl.c
index 8aaeaa069019b6936408d54d8bad95ff465e07e2..3b4d5b187ca3e9efe328be60871eb0e00fefad07 100644 (file)
@@ -218,23 +218,18 @@ static int php_http_curle_progress_callback(void *ctx, double dltotal, double dl
        return 0;
 }
 
-static curlioerr php_http_curle_ioctl_callback(CURL *ch, curliocmd cmd, void *ctx)
+static int php_http_curle_seek_callback(void *userdata, curl_off_t offset, int origin)
 {
-       php_http_message_body_t *body = ctx;
+       php_http_message_body_t *body = userdata;
+       TSRMLS_FETCH_FROM_CTX(body->ts);
 
-       if (cmd != CURLIOCMD_RESTARTREAD) {
-               return CURLIOE_UNKNOWNCMD;
+       if (!body) {
+               return 1;
        }
-
-       if (body) {
-               TSRMLS_FETCH_FROM_CTX(body->ts);
-
-               if (SUCCESS == php_stream_rewind(php_http_message_body_stream(body))) {
-                       return CURLIOE_OK;
-               }
+       if (0 == php_stream_seek(php_http_message_body_stream(body), offset, origin)) {
+               return 0;
        }
-
-       return CURLIOE_FAILRESTART;
+       return 2;
 }
 
 static int php_http_curle_raw_callback(CURL *ch, curl_infotype type, char *data, size_t length, void *ctx)
@@ -415,17 +410,6 @@ static STATUS php_http_curle_get_info(CURL *ch, HashTable *info)
                add_assoc_zval_ex(&array, "ssl_engines", sizeof("ssl_engines"), subarray);
                curl_slist_free_all(s);
        }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_COOKIELIST, &s)) {
-               MAKE_STD_ZVAL(subarray);
-               array_init(subarray);
-               for (p = s; p; p = p->next) {
-                       if (p->data) {
-                               add_next_index_string(subarray, p->data, 1);
-                       }
-               }
-               add_assoc_zval_ex(&array, "cookies", sizeof("cookies"), subarray);
-               curl_slist_free_all(s);
-       }
        if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_REDIRECT_URL, &c)) {
                add_assoc_string_ex(&array, "redirect_url", sizeof("redirect_url"), c ? c : "", 1);
        }
@@ -1215,6 +1199,13 @@ static void php_http_curle_options_init(php_http_options_t *registry TSRMLS_DC)
        }
 #endif
 
+#if PHP_HTTP_CURL_VERSION(7,40,0)
+       if ((opt = php_http_option_register(registry, ZEND_STRL("unix_socket_path"), CURLOPT_UNIX_SOCKET_PATH, IS_STRING))) {
+               opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
+               opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR;
+       }
+#endif
+
        /* dns */
        if ((opt = php_http_option_register(registry, ZEND_STRL("dns_cache_timeout"), CURLOPT_DNS_CACHE_TIMEOUT, IS_LONG))) {
                Z_LVAL(opt->defval) = 60;
@@ -1677,7 +1668,7 @@ static php_http_client_curl_handler_t *php_http_client_curl_handler_init(php_htt
        curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, php_http_curle_body_callback);
        curl_easy_setopt(handle, CURLOPT_DEBUGFUNCTION, php_http_curle_raw_callback);
        curl_easy_setopt(handle, CURLOPT_READFUNCTION, php_http_curle_read_callback);
-       curl_easy_setopt(handle, CURLOPT_IOCTLFUNCTION, php_http_curle_ioctl_callback);
+       curl_easy_setopt(handle, CURLOPT_SEEKFUNCTION, php_http_curle_seek_callback);
 #if PHP_HTTP_CURL_VERSION(7,32,0)
        curl_easy_setopt(handle, CURLOPT_XFERINFOFUNCTION, php_http_curle_xferinfo_callback);
        curl_easy_setopt(handle, CURLOPT_XFERINFODATA, handler);
@@ -1743,6 +1734,9 @@ static STATUS php_http_client_curl_handler_prepare(php_http_client_curl_handler_
                }
        }
 
+       /* apply options */
+       php_http_options_apply(&php_http_curle_options, enqueue->options, curl);
+
        /* request headers */
        php_http_message_update_headers(msg);
        if (zend_hash_num_elements(&msg->hdrs)) {
@@ -1787,19 +1781,17 @@ static STATUS php_http_client_curl_handler_prepare(php_http_client_curl_handler_
                 * does not allow a request body.
                 */
                php_stream_rewind(php_http_message_body_stream(msg->body));
-               curl_easy_setopt(curl->handle, CURLOPT_IOCTLDATA, msg->body);
+               curl_easy_setopt(curl->handle, CURLOPT_SEEKDATA, msg->body);
                curl_easy_setopt(curl->handle, CURLOPT_READDATA, msg->body);
                curl_easy_setopt(curl->handle, CURLOPT_INFILESIZE, body_size);
                curl_easy_setopt(curl->handle, CURLOPT_POSTFIELDSIZE, body_size);
        } else {
-               curl_easy_setopt(curl->handle, CURLOPT_IOCTLDATA, NULL);
+               curl_easy_setopt(curl->handle, CURLOPT_SEEKDATA, NULL);
                curl_easy_setopt(curl->handle, CURLOPT_READDATA, NULL);
                curl_easy_setopt(curl->handle, CURLOPT_INFILESIZE, 0L);
                curl_easy_setopt(curl->handle, CURLOPT_POSTFIELDSIZE, 0L);
        }
 
-       php_http_options_apply(&php_http_curle_options, enqueue->options, curl);
-
        return SUCCESS;
 }