@@ -191,7 +191,6 @@ struct CurlInitializer {
191
191
curl_global_cleanup ();
192
192
}
193
193
};
194
-
195
194
}
196
195
197
196
NetworkClient::NetworkClient ():
@@ -211,7 +210,7 @@ NetworkClient::NetworkClient():
211
210
{
212
211
static NetworkClientInternal::CurlInitializer initializer;
213
212
214
- *m_errorBuffer = 0 ;
213
+ *errorBuffer_ = 0 ;
215
214
curlHandle_ = curl_easy_init ();
216
215
bodyFuncData_.funcType = funcTypeBody;
217
216
bodyFuncData_.nmanager = this ;
@@ -225,7 +224,7 @@ NetworkClient::NetworkClient():
225
224
curl_easy_setopt (curlHandle_, CURLOPT_WRITEFUNCTION, private_static_writer);
226
225
curl_easy_setopt (curlHandle_, CURLOPT_WRITEDATA, &bodyFuncData_);
227
226
curl_easy_setopt (curlHandle_, CURLOPT_WRITEHEADER, &headerFuncData_);
228
- curl_easy_setopt (curlHandle_, CURLOPT_ERRORBUFFER, m_errorBuffer );
227
+ curl_easy_setopt (curlHandle_, CURLOPT_ERRORBUFFER, errorBuffer_ );
229
228
230
229
curl_easy_setopt (curlHandle_, CURLOPT_PROGRESSFUNCTION, &private_progress_func);
231
230
curl_easy_setopt (curlHandle_, CURLOPT_NOPROGRESS, 0L );
@@ -340,7 +339,7 @@ size_t NetworkClient::private_progress_func(void* clientp, double dltotal, doubl
340
339
}
341
340
342
341
void NetworkClient::setMethod (const NString& str) {
343
- m_method = str;
342
+ method_ = str;
344
343
}
345
344
346
345
void NetworkClient::addQueryParam (const NString& name, const NString& value) {
@@ -368,9 +367,10 @@ void NetworkClient::setUrl(const NString& url) {
368
367
}
369
368
370
369
bool NetworkClient::doUploadMultipartData () {
371
- if (m_method .empty ()) {
370
+ if (method_ .empty ()) {
372
371
setMethod (" POST" );
373
372
}
373
+
374
374
private_init_transfer ();
375
375
private_apply_method ();
376
376
@@ -486,7 +486,7 @@ NString NetworkClient::urlEncode(const NString& str) {
486
486
}
487
487
488
488
NString NetworkClient::errorString () const {
489
- return m_errorBuffer ;
489
+ return errorBuffer_ ;
490
490
}
491
491
492
492
void NetworkClient::setUserAgent (const NString& userAgentStr) {
@@ -575,7 +575,7 @@ void NetworkClient::private_cleanup_after() {
575
575
outFile_ = nullptr ;
576
576
}
577
577
outFileName_.clear ();
578
- m_method .clear ();
578
+ method_ .clear ();
579
579
curl_easy_setopt (curlHandle_, CURLOPT_INFILESIZE_LARGE, static_cast <curl_off_t >(-1 ));
580
580
581
581
uploadData_.clear ();
@@ -663,6 +663,7 @@ bool NetworkClient::doUpload(const NString& fileName, const NString& data) {
663
663
/* if (m_method != "PUT") {
664
664
addQueryHeader("Content-Length", std::to_string(currentUploadDataSize_));
665
665
}*/
666
+ curl_easy_setopt (curlHandle_, CURLOPT_POSTFIELDSIZE_LARGE, static_cast <curl_off_t >(currentUploadDataSize_));
666
667
667
668
curl_easy_setopt (curlHandle_, CURLOPT_INFILESIZE_LARGE, static_cast <curl_off_t >(currentUploadDataSize_));
668
669
@@ -676,14 +677,14 @@ bool NetworkClient::doUpload(const NString& fileName, const NString& data) {
676
677
bool NetworkClient::private_apply_method () {
677
678
curl_easy_setopt (curlHandle_, CURLOPT_CUSTOMREQUEST,nullptr );
678
679
curl_easy_setopt (curlHandle_, CURLOPT_UPLOAD, 0L );
679
- if (m_method == " POST" )
680
+ if (method_ == " POST" )
680
681
curl_easy_setopt (curlHandle_, CURLOPT_POST, 1L );
681
- else if (m_method == " GET" )
682
+ else if (method_ == " GET" )
682
683
curl_easy_setopt (curlHandle_, CURLOPT_HTTPGET, 1L );
683
- else if (m_method == " PUT" )
684
+ else if (method_ == " PUT" )
684
685
curl_easy_setopt (curlHandle_, CURLOPT_UPLOAD, 1L );
685
- else if (!m_method .empty ()) {
686
- curl_easy_setopt (curlHandle_, CURLOPT_CUSTOMREQUEST, m_method .c_str ());
686
+ else if (!method_ .empty ()) {
687
+ curl_easy_setopt (curlHandle_, CURLOPT_CUSTOMREQUEST, method_ .c_str ());
687
688
} else {
688
689
curl_easy_setopt (curlHandle_, CURLOPT_CUSTOMREQUEST, nullptr );
689
690
return false ;
0 commit comments