@@ -354,23 +354,6 @@ ofHttpResponse ofURLFileLoaderImpl::handleRequest(const ofHttpRequest & request)
354354 if (headers) {
355355 curl_easy_setopt (curl.get (), CURLOPT_HTTPHEADER, headers);
356356 }
357- std::string body = request.body ;
358- if (!request.body .empty ()) {
359- if (request.method == ofHttpRequest::PUT || request.body .size () > MAX_POSTFIELDS_SIZE) { // If request is an upload (e.g., file upload)
360- curl_easy_setopt (curl.get (), CURLOPT_UPLOAD, 1L );
361- curl_easy_setopt (curl.get (), CURLOPT_READFUNCTION, readBody_cb);
362- curl_easy_setopt (curl.get (), CURLOPT_READDATA, &body);
363- curl_easy_setopt (curl.get (), CURLOPT_POSTFIELDSIZE, 0L );
364- } else { // If request is a normal POST
365- curl_easy_setopt (curl.get (), CURLOPT_POSTFIELDSIZE, request.body .size ());
366- curl_easy_setopt (curl.get (), CURLOPT_POSTFIELDS, request.body .c_str ());
367- }
368- } else {
369- curl_easy_setopt (curl.get (), CURLOPT_POSTFIELDSIZE, 0L );
370- curl_easy_setopt (curl.get (), CURLOPT_POSTFIELDS, " " );
371- curl_easy_setopt (curl.get (), CURLOPT_READFUNCTION, nullptr );
372- curl_easy_setopt (curl.get (), CURLOPT_READDATA, nullptr );
373- }
374357 if (request.method == ofHttpRequest::GET) {
375358 curl_easy_setopt (curl.get (), CURLOPT_HTTPGET, 1L );
376359 curl_easy_setopt (curl.get (), CURLOPT_POST, 0L );
@@ -386,6 +369,25 @@ ofHttpResponse ofURLFileLoaderImpl::handleRequest(const ofHttpRequest & request)
386369 curl_easy_setopt (curl.get (), CURLOPT_UPLOAD, 0L );
387370 curl_easy_setopt (curl.get (), CURLOPT_HTTPGET, 0L );
388371 }
372+ if (request.method != ofHttpRequest::GET) {
373+ std::string body = request.body ;
374+ if (!request.body .empty ()) {
375+ if (request.method == ofHttpRequest::PUT || request.body .size () > MAX_POSTFIELDS_SIZE) { // If request is an upload (e.g., file upload)
376+ curl_easy_setopt (curl.get (), CURLOPT_UPLOAD, 1L );
377+ curl_easy_setopt (curl.get (), CURLOPT_READFUNCTION, readBody_cb);
378+ curl_easy_setopt (curl.get (), CURLOPT_READDATA, &body);
379+ curl_easy_setopt (curl.get (), CURLOPT_POSTFIELDSIZE, 0L );
380+ } else { // If request is a normal POST
381+ curl_easy_setopt (curl.get (), CURLOPT_POSTFIELDSIZE, request.body .size ());
382+ curl_easy_setopt (curl.get (), CURLOPT_POSTFIELDS, request.body .c_str ());
383+ }
384+ } else {
385+ curl_easy_setopt (curl.get (), CURLOPT_POSTFIELDSIZE, 0L );
386+ curl_easy_setopt (curl.get (), CURLOPT_POSTFIELDS, " " );
387+ curl_easy_setopt (curl.get (), CURLOPT_READFUNCTION, nullptr );
388+ curl_easy_setopt (curl.get (), CURLOPT_READDATA, nullptr );
389+ }
390+ }
389391
390392 if (request.timeoutSeconds > 0 ) {
391393 curl_easy_setopt (curl.get (), CURLOPT_TIMEOUT, request.timeoutSeconds );
0 commit comments