static int http_curl_progress_callback(void *, double, double, double, double);
static int http_curl_raw_callback(CURL *, curl_infotype, char *, size_t, void *);
static int http_curl_dummy_callback(char *data, size_t n, size_t l, void *s) { return n*l; }
+static curlioerr http_curl_ioctl_callback(CURL *, curliocmd, void *);
/* {{{ http_request_callback_ctx http_request_callback_data(void *) */
http_request_callback_ctx *_http_request_callback_data_ex(void *data, zend_bool cpy TSRMLS_DC)
HTTP_CURL_OPT(FILETIME, 1);
HTTP_CURL_OPT(AUTOREFERER, 1);
HTTP_CURL_OPT(READFUNCTION, http_curl_read_callback);
+ HTTP_CURL_OPT(IOCTLFUNCTION, http_curl_ioctl_callback);
/* we'll get all data through the debug function */
HTTP_CURL_OPT(WRITEFUNCTION, http_curl_dummy_callback);
HTTP_CURL_OPT(HEADERFUNCTION, NULL);
break;
case HTTP_REQUEST_BODY_UPLOADFILE:
+ curl_easy_setopt(ch, CURLOPT_IOCTLDATA, http_request_callback_data(body));
curl_easy_setopt(ch, CURLOPT_READDATA, http_request_callback_data(body));
curl_easy_setopt(ch, CURLOPT_INFILESIZE, body->size);
break;
}
/* }}} */
+/* {{{ static curlioerr http_curl_ioctl_callback(CURL *, curliocmd, void *) */
+static curlioerr http_curl_ioctl_callback(CURL *ch, curliocmd cmd, void *ctx)
+{
+ HTTP_REQUEST_CALLBACK_DATA(ctx, http_request_body *, body);
+
+ if (cmd != CURLIOCMD_RESTARTREAD) {
+ return CURLIOE_UNKNOWNCMD;
+ }
+ if (body->type != HTTP_REQUEST_BODY_UPLOADFILE) {
+ return CURLIOE_FAILRESTART;
+ }
+ if (SUCCESS != php_stream_rewind((php_stream *) body->data)) {
+ return CURLIOE_FAILRESTART;
+ }
+ return CURLIOE_OK;
+}
+/* }}} */
+
/* {{{ static int http_curl_raw_callback(CURL *, curl_infotype, char *, size_t, void *) */
static int http_curl_raw_callback(CURL *ch, curl_infotype type, char *data, size_t length, void *ctx)
{
HTTP_CURL_OPT(POSTFIELDS, NULL);
HTTP_CURL_OPT(POSTFIELDSIZE, 0);
HTTP_CURL_OPT(HTTPPOST, NULL);
+ HTTP_CURL_OPT(IOCTLDATA, NULL);
HTTP_CURL_OPT(READDATA, NULL);
HTTP_CURL_OPT(INFILESIZE, 0);
}