Vittorio Romeo
Vittorio Romeo

Reputation: 93264

Sending a post request via C++ desktop application

I'm using SFML::Network to access my web server and send it high scores. The high scores are recieved by a PHP script that stores them on a JSON file:

...
$name = $_POST["n"];
$validator = $_POST["v"];
$score = $_POST["s"];
...

I'm currently sending a POST request from C++ like this:

...
Http http; http.setHost("http://mywebsite.com");
Request request("script.php", Http::Request::Post);
request.setBody("n=" + mName + "&v=" + mValidator + "&s=" + toStr(mScore));
http.sendRequest(request);
...

This works, but has the same limitations as a GET request - especially character limit. Since I need to validate the high scores for custom levels made in LUA, I wanted to pass the whole LUA file (stripped of symbols and whitespace) as mValidator. But it doesn't work with 1000 characters. Small strings work properly.

I've been told that character limit is only present in GET requests, and that I'm calling the POST request in the wrong way.

How can I call the POST request correctly and avoid the character limit without compressing my parameters?

Upvotes: 0

Views: 627

Answers (1)

mark
mark

Reputation: 5449

1000 characters should work fine. Check to make sure your string is properly encoded. A content-type of x-www-form-urlencoded should be URL encoded.

Upvotes: 1

Related Questions