Skip to content

Commit f6ff8eb

Browse files
authored
Merge pull request #97 from Adonai/master
2 parents d9c54b5 + 8fb9948 commit f6ff8eb

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

include/curl_form.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ namespace curl {
8686
* contents to the form contents list.
8787
*/
8888
void add(const curl_pair<CURLformoption,std::string> &, const curl_pair<CURLformoption,std::string> &, const curl_pair<CURLformoption,int> &, const curl_pair<CURLformoption,std::string> &);
89+
/**
90+
* Overloaded add method. Used primarily to pass data via CURLFORM_BUFFERPTR.
91+
* E.g. first option is content name, second is buffer name,
92+
* third is buffer data pointer, fourth is buffer length.
93+
*/
94+
void add(const curl_pair<CURLformoption,std::string> &, const curl_pair<CURLformoption,std::string> &, const curl_pair<CURLformoption, char*> &, const curl_pair<CURLformoption,long> &);
8995
/**
9096
* Overloaded add method. This version is primarily used to upload multiple files.
9197
* You can pass a vector of filenames to upload them.

src/curl_form.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,18 @@ void curl_form::add(const curl_pair<CURLformoption,string> &form_name, const cur
102102
}
103103
}
104104

105+
// Implementation of add overloaded method for CURLFORM_BUFFERPTR uses
106+
void curl_form::add(const curl_pair<CURLformoption,string> &form_name, const curl_pair<CURLformoption,string> &form_bufname, const curl_pair<CURLformoption, char*> &form_content, const curl_pair<CURLformoption,long> &content_length) {
107+
if (curl_formadd(&this->form_post,&this->last_ptr,
108+
form_name.first(),form_name.second(),
109+
form_bufname.first(),form_bufname.second(),
110+
form_content.first(),form_content.second(),
111+
content_length.first(),content_length.second(),
112+
CURLFORM_END) != 0) {
113+
throw curl_exception("Error while adding the form",__FUNCTION__);
114+
}
115+
}
116+
105117
/**
106118
* If you want to upload more than one file, you can pass the form name and a
107119
* vector of filenames.

0 commit comments

Comments
 (0)