Hello.
I'm trying to create a function to make GET and POST requests, but I'm having difficulties. I can't find the error.
I would be immensely grateful for the help.
Taking advantage, wouldn't there be an easier way to add headers to a request, without having to create three different objects
#pragma plugin nvgt_curl
string file_get_contents(string url, string path="/", bool post=false, string userAgent="Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.12011-10-16 20:23:00"){
http_request request((!post? HTTP_GET: HTTP_POST), path);
http_response response;
https_client client(url);
request["User-Agent"] = userAgent;
client.send_request(request);
datastream@ ds = client.receive_response(response);
return ds.read();
}
void main() {
alert("test", file_get_contents("samtupy.com"));
}