Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6552355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:26:59+00:00 2026-05-25T12:26:59+00:00

UPDATED: Problem was not in libcurl. The right way to cancel request if to

  • 0

UPDATED: Problem was not in libcurl. The right way to cancel request if to return from callback non-zero value. I used curl_progress_callback function, and everything works fine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:27:00+00:00Added an answer on May 25, 2026 at 12:27 pm

    What you need to understand is that CURL is a C library. In general, you cannot pass pointers to C++ objects or functions because C does not know anything about C++’s classes and calling convention.

    For example, this line is incorrect:

    curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorBuffer);
    

    CURL setopt CURLOPT_ERRORBUFFER expects that the third parameter is a pointer to a C-style string (C-style char array) having space for CURL_ERROR_SIZE chars. You are instead passing a pointer to a std::string object. As CURL, being written in C, does not know what a std::string is, it simply overwrites the byte representation having sizeof (std::string) bytes with the error data because it thinks that the pointer is to a C-style char array.

    Use this instead:

    char errorBuffer[CURL_ERROR_SIZE + 1]; errorBuffer[CURL_ERROR_SIZE] = '\0';
    curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorBuffer);
    

    errorBuffer is only filled with a valid string if curl_easy_perform() returns an error code.

    Also, Uploader::WriteResponce is a C++ function. With this line:

    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteResponce);
    

    CURL expects the third parameter to be a pointer-to-C function. Here, you are passing a pointer-to-C++ function. You need to wrap the call to WriteResponce in an extern "C" function that calls the C++ function:

    extern "C" size_t call_uploader_writeresponce(char *ptr, size_t size, size_t nmemb, void *user_data) {
        return Uploader::WriteResponce(ptr, size, nmemb, static_cast<std::string *>(user_data));
    }
    
    
    // ...
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &call_uploader_writeresponce);
    

    The “write function” needs to return size_t, not int; Uploader::WriteResponce needs to return size_t.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

UPDATED I used below solutions (loading Image from stream), but get new problem. img
This is not a new problem for me. From C to PERL to Python
I have a problem with updating the value of property from code which is
Problem: I updated the wrong table in the database. Is there any way to
The problem is not solved although I accepted one answer. Problem: Vim updates very
[Updated, sorry about the change but now to the real problem] I cannot include
I have a website that is updated regularly and I am having a problem
[Update]: my initial example doesn't reflect my problem. Updated the sample, hopfully it is
I've recently updated 1 logging component to log Exception.ToString rather than Exception.Message.ToString(), the problem
My problem is deleting a node from linked list. I have two structs :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.