Coder Social home page Coder Social logo

Comments (7)

JosephP91 avatar JosephP91 commented on May 21, 2024

Hi @foreverska !
You can still initialize a curl_easy object with a curl_ios instance. What kind of problem you encountered?
For example:

#include "curl_easy.h"
#include "curl_form.h"
#include "curl_exception.h"
#include "curl_header.h"

using curl::curl_header;
using curl::curl_easy;
using std::ostringstream;

int main() {
    ostringstream str;
    // Let's create an object which will contain a list of headers.
    curl_header header;
    // Easy object to handle the connection.
    curl_ios<ostringstream> ios(str);
    curl_easy easy(ios);

    // Add custom headers.
    header.add("Accept:");
    header.add("Another:yes");
    header.add("Host: example.com");

    // Add the headers to the easy object.
    easy.add<CURLOPT_HTTPHEADER>(header.get());

    easy.add<CURLOPT_URL>("http://www.example.com");
    //easy.add<CURLOPT_VERBOSE>(1L);
    try {
        // Request execution
        easy.perform();
    } catch (curl_easy_exception error) {
        // If you want to get the entire error stack we can do:
        curlcpp_traceback errors = error.get_traceback();
        // Otherwise we could print the stack like this:
        error.print_traceback();
    }
    cout<<str.str()<<endl;
    return 0;
}

from curlcpp.

foreverska avatar foreverska commented on May 21, 2024

The error which titles this issue happens when I try to compile the example to put the response in a variable given in the README and my own code which at the time was modeled directly after it. g++ goes on to list the possible function candidates none of which are close to initialization with a curl_ios instance.

from curlcpp.

JosephP91 avatar JosephP91 commented on May 21, 2024

@foreverska Ok, can you post the piece of code where you are initializing curl_easy and declaring curl_ios?

from curlcpp.

foreverska avatar foreverska commented on May 21, 2024

For testing I copied and pasted the code provided in the README (the 4th Simple Usage Example) into a local file called test.cpp file and compiled it and here is the output:

adam@adam-PC:~/Documents/Programming/config/neo4j$ g++ -std=c++11 src/test.cpp -I inc/ -I ../../vendor/curlcpp/include/ -L ../../vendor/curlcpp/build/src/ -lcurlcpp -lcurl
src/test.cpp: In function ‘int main()’:
src/test.cpp:13:26: error: no matching function for call to ‘curl::curl_easy::curl_easy(curl::curl_ios<std::__cxx11::basic_ostringstream<char> >&)’
     curl_easy easy(writer);
                          ^
In file included from src/test.cpp:1:0:
../../vendor/curlcpp/include/curl_easy.h:893:9: note: candidate: curl::curl_easy::curl_easy(const curl::curl_easy&)
         curl_easy(const curl_easy &);
         ^
../../vendor/curlcpp/include/curl_easy.h:893:9: note:   no known conversion for argument 1 from ‘curl::curl_ios<std::__cxx11::basic_ostringstream<char> >’ to ‘const curl::curl_easy&’
../../vendor/curlcpp/include/curl_easy.h:888:18: note: candidate: curl::curl_easy::curl_easy(long int)
         explicit curl_easy(const long);
                  ^
../../vendor/curlcpp/include/curl_easy.h:888:18: note:   no known conversion for argument 1 from ‘curl::curl_ios<std::__cxx11::basic_ostringstream<char> >’ to ‘long int’
../../vendor/curlcpp/include/curl_easy.h:883:9: note: candidate: curl::curl_easy::curl_easy()
         curl_easy();
         ^
../../vendor/curlcpp/include/curl_easy.h:883:9: note:   candidate expects 0 arguments, 1 provided

from curlcpp.

JosephP91 avatar JosephP91 commented on May 21, 2024

@foreverska Holy cow! Two methods implementation were missing. I pushed a fix right now. Can you update your curlcpp local version and let me know if the problem is fixed?

from curlcpp.

foreverska avatar foreverska commented on May 21, 2024

I did a pull and now test.cpp compiles and runs correctly.

I already migrated my code to the recv_header.cpp style code so all I can say about that is the push didn't break anything for me. But this will be very helpful for new people.

from curlcpp.

JosephP91 avatar JosephP91 commented on May 21, 2024

Very well! Thank you!

from curlcpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.