Я пытаюсь выполнить несколько запросов HTTP ( S ) с помощью cpp -httplib. Почему
#include <iostream>
#include "httplib.h"
using namespace std;
int main()
{
cout << "hi" << endl;
auto res = httplib::Client("http://stackoverflow.com").Get("/");
cout << res << endl;
return 0;
}
печатает
hi
0x5605c058db50
(ОК), но
#include <iostream>
#include "httplib.h"
using namespace std;
int main()
{
cout << "hi" << endl;
auto res = httplib::Client("https://stackoverflow.com").Get("/");
cout << res << endl;
return 0;
}
(тот же код, только что http
заменен на https
)
hi
Segmentation fault (core dumped)
?
GDB backtrace
дает мне это после segfault:
#0 0x000055555555eee8 in httplib::ClientImpl::Socket::is_open (this=0x50) at /home/viktor/delayWatcher/cpp-fetcher/libs/httplib.h:822
#1 0x0000555555569a20 in httplib::ClientImpl::send (this=0x0, req=..., res=...) at /home/viktor/delayWatcher/cpp-fetcher/libs/httplib.h:4579
#2 0x000055555556bb8b in httplib::ClientImpl::Get(char const*, std::multimap<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, httplib::detail::ci, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > const&, std::function<bool (unsigned long, unsigned long)>) (this=0x0, path=0x5555555bc887 "/", headers=std::multimap with 0 elements, progress=...) at /home/viktor/delayWatcher/cpp-fetcher/libs/httplib.h:4980
#3 0x000055555556ba1d in httplib::ClientImpl::Get (this=0x0, path=0x5555555bc887 "/") at /home/viktor/delayWatcher/cpp-fetcher/libs/httplib.h:4958
#4 0x000055555556c345 in httplib::Client::Get (this=0x7fffffffe320, path=0x5555555bc887 "/") at /home/viktor/delayWatcher/cpp-fetcher/libs/httplib.h:6015
#5 0x000055555555d767 in main () at /home/viktor/delayWatcher/cpp-fetcher/fetcher/main.cpp:11