Comments (7)
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.
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.
@foreverska Ok, can you post the piece of code where you are initializing curl_easy and declaring curl_ios?
from curlcpp.
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.
@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.
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.
Very well! Thank you!
from curlcpp.
Related Issues (20)
- warnings when building
- NOEXCEPT
- Release:1.2 Cmake fails. HOT 15
- compile warning: invalid use of incomplete type HOT 2
- curl_easy_exception doesn't set any message into std::exception HOT 1
- Build of 1.4 fail with mingw32 in win10 and curl 7.74.0 HOT 12
- Can't link on windows HOT 3
- Singleton initializer issue HOT 1
- replece curlcpp-master/include to curlcpp-master/include/curlcpp
- Can't link with a project with Dynamic CRT (VS2019)
- initialising order warnings HOT 1
- Is a new tag/release coming soon? HOT 1
- build fail with curl 7.83.0 HOT 2
- Static build? HOT 6
- Deprecation warnings with latest curl version
- How to get response content string when using curl_multi HOT 1
- Version inside CMake looks out of date HOT 1
- suggestion libev
- Titles in README.md mismatch
- BUILD_SHARED_LIBS non-standard usage.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from curlcpp.