const char *content_type, http_formdata_type_e type)
{
__http_transaction_h *transaction = (__http_transaction_h *)http_transaction;
+ CURL *handle = transaction->easy_handle;
+ _retm_if(handle == NULL, "parameter(handle) is NULL\n");
+
__http_request_h *request = transaction->request;
- CURLformoption option = CURLFORM_COPYCONTENTS;
-
- if (type == HTTP_MULTIPART_CONTENTS)
- option = CURLFORM_COPYCONTENTS;
- else if (type == HTTP_MULTIPART_FILE)
- option = CURLFORM_FILE;
-
- if (content_type) {
- curl_formadd(&(request->formpost),
- &(request->lastptr),
- CURLFORM_COPYNAME, part_name,
- option, value,
- CURLFORM_CONTENTTYPE, content_type,
- CURLFORM_END);
- } else {
- curl_formadd(&(request->formpost),
- &(request->lastptr),
- CURLFORM_COPYNAME, part_name,
- option, value,
- CURLFORM_END);
- }
+ _retm_if(request == NULL, "parameter(request) is NULL\n");
+
+ curl_mime *multipart = curl_mime_init(handle);
+ curl_mimepart *part = curl_mime_addpart(multipart);
+ curl_mime_name(part, part_name);
+
+ if (type == HTTP_MULTIPART_FILE)
+ curl_mime_filedata(part, value);
+ else
+ curl_mime_data(part, value, CURL_ZERO_TERMINATED);
+
+ if (content_type)
+ curl_mime_type(part, content_type);
+
+
+ request->multipart = multipart;
+ request->part = part;
}
//LCOV_EXCL_STOP
return 0;
}
-int __progress_cb(void *user_data, double dltotal, double dlnow, double ultotal, double ulnow)
+int __progress_cb(void *user_data,
+ curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
{
__http_transaction_h *transaction = (__http_transaction_h *)user_data;
if (transaction->write_event)
write_event = TRUE;
- DBG("The write_event[%d/%d] formpost[%d] upload_event[%d]\n",
+ DBG("The write_event[%d/%d] multipart[%d] upload_event[%d]\n",
transaction->write_event,
- write_event, (request->formpost) ? 1 : 0,
+ write_event, (request->multipart) ? 1 : 0,
transaction->upload_event);
- if ((_get_method(request->method) == HTTP_METHOD_POST) && !write_event && !request->formpost) {
+ if ((_get_method(request->method) == HTTP_METHOD_POST) && !write_event && !request->multipart) {
gchar *body = NULL;
ret = _read_request_body(transaction, &body);
}
/* Mulipart POST */
- if (request->formpost)
- curl_easy_setopt(transaction->easy_handle, CURLOPT_HTTPPOST, request->formpost);
+ if (request->multipart)
+ curl_easy_setopt(transaction->easy_handle, CURLOPT_MIMEPOST, request->multipart);
/* Setup for PUT method */
if (transaction->upload_event) {
}
curl_easy_setopt(transaction->easy_handle, CURLOPT_NOPROGRESS, FALSE);
- curl_easy_setopt(transaction->easy_handle, CURLOPT_PROGRESSFUNCTION, __progress_cb);
- curl_easy_setopt(transaction->easy_handle, CURLOPT_PROGRESSDATA, transaction);
+ curl_easy_setopt(transaction->easy_handle, CURLOPT_XFERINFOFUNCTION, __progress_cb);
+ curl_easy_setopt(transaction->easy_handle, CURLOPT_XFERINFODATA, transaction);
curl_easy_setopt(transaction->easy_handle, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(transaction->easy_handle, CURLOPT_DEBUGFUNCTION, __http_debug_received);
transaction->request->upload_size = 0;
transaction->request->upload_file = NULL;
transaction->request->fp = NULL;
- transaction->request->formpost = NULL;
- transaction->request->lastptr = NULL;
+ transaction->request->multipart = NULL;
+ transaction->request->part = NULL;
/* Response */
transaction->response->status_text = NULL;
if (request->body_queue != NULL)
g_queue_free(request->body_queue);
- if (request->formpost) {
- curl_formfree(request->formpost);
- request->formpost = NULL;
+ if (request->multipart) {
+ curl_mime_free(request->multipart);
+ request->multipart = NULL;
+ request->part = NULL;
}
if (request->upload_file != NULL) {