Use POST instead of GET for uploading rankings
The highlighted comment was created in this 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
Practically, is this going to make any difference? I think the slowest part of processing a result is by far the database activity. "It works as is" is a pretty good reason up against virtually no impact. :-)
Also, I did some quick Googling to see how much faster it is, and it seems like everyone says they're the same or GET is faster.
(If we are going to change the protocol, maybe we should go with SPDY. ;) jk)