This is my libcurl request (curl_example.cpp)
#include <iostream>
#include <string>
#include <curl/curl.h>
#include <vector>
#include <fstream> // std::ifstream
using namespace std;
using namespace cv;
static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}
int main(void)
{
CURL *curl;
CURLcode res;
std::string readBuffer;
int length=80000;
char c = 'z';
string encoded_png=std::string(length, c);
std::string url_data="http://0.0.0.0:18080/params?query="+encoded_png;
struct curl_slist *headerlist=NULL;
curl = curl_easy_init();
if(curl)
{
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(curl, CURLOPT_URL,url_data.c_str()) ;
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
std::cout <<"readBuffer:"<< readBuffer << std::endl;
}
return 0;
}
This is my Crow c++ server code (crow_example.cpp)
#include<iostream>
#include "crow.h"
#include<string>
using namespace std;
int main()
{
crow::SimpleApp app;
CROW_ROUTE(app, "/params")
([](const crow::request& req){
std::ostringstream os;
// To get a simple string from the url params
// To see it in action /params?foo='blabla'
os << "Params: " << req.url_params << "\n\n";
os << "The string received is " << (req.url_params.get("query") == nullptr ? "not " : "") << "found.\n";
return crow::response{os.str()};
});
app.port(18080).multithreaded().run();
}
with length=80000; When I run the crow c++ server and query the server with libcurl I could able to receive the string in crow as well as get the response in curl.
with length = 85000;.//more than 80,000 I am not able to receive any string at the crow server as well there is no response from the libcurl request.
With the python flask server, I could receive the string with any length. But the crow server is not working and I am not able to figure out what is the rootcause.
Any help or inputs appreciated.