Use POST instead of GET for uploading rankings
From Talk:RoboRumble
Jump to navigation
Jump to search
Revision as of 31 March 2012 at 09:58.
This is the thread's initial revision.
This is the thread's initial revision.
Some slight modification will need to be made to both the server and the client. But the only excuse I can really think against it is that 'it works as is'. But post is faster, and not really hard to do on either side.
How to use post on the serverside.
<?php
$postTotal = $_POST['total'];
for($i=0;$i<$postTotal;$i++) {
handleUpload($_POST['r'.$i]);
}
?>
Wooo done, barring some parsing that should be already written.
How to use post in Java
public static final String sendPostAndGetReply(final URL url, final String post) throws IOException {
URLConnection conn = url.openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setUseCaches(false);
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
DataOutputStream out = new DataOutputStream(conn.getOutputStream());
out.writeBytes(post);
out.flush();
out.close();
//IOToolkit.getAndClose just gets all the bytes from a stream then closes it
return new String(IOToolkit.getAndClose(conn.getInputStream()),"UTF-8");
}
Barring some encoding which is also already done.
I know the encoded string looks something like this, except URL encoded.
- roborumble,1,800x800,Chase,1326909734701,SERVER;cs.pm.Pytko 1.1,119,49,1;cs.ExclusionNano 1.1,19,19,0