Use POST instead of GET for uploading rankings

Jump to navigation Jump to search

Use POST instead of GET for uploading rankings

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
Chase-san11:58, 31 March 2012

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)

Voidious15:19, 31 March 2012
 

You do not have permission to edit this page, for the following reasons:

  • The action you have requested is limited to users in the group: Users.
  • You must confirm your email address before editing pages. Please set and validate your email address through your user preferences.

You can view and copy the source of this page.

Return to Thread:Talk:RoboRumble/Use POST instead of GET for uploading rankings/reply (2).

 

Ah, are they, that is sorta what I ment, meaning you can just bundle all of them in a POST and upload them all at once. I figured it was still using GET, which makes batching more difficult.

Chase-san05:09, 1 April 2012