Thread history

From Talk:RoboRumble
Viewing a history listing
Jump to navigation Jump to search
Time User Activity Comment
04:09, 1 April 2012 Chase-san (talk | contribs) New reply created (Reply to Use POST instead of GET for uploading rankings)
16:20, 31 March 2012 MN (talk | contribs) New reply created (Reply to Use POST instead of GET for uploading rankings)
14:19, 31 March 2012 Voidious (talk | contribs) New reply created (Reply to Use POST instead of GET for uploading rankings)
10:58, 31 March 2012 Chase-san (talk | contribs) New thread created  

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-san10: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)

Voidious14:19, 31 March 2012
 

I remember POST already being used for uploads the last time I checked the client code. And the main difference between GET and POST is not raw performance, but how proxy servers deal with them. GET is usually cached while POST isn´t.

To increase upload speed, batch uploads (everything in a single request) and batch inserts in the database (everything in a single commit) would do a better job.

MN16:20, 31 March 2012
 

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-san04:09, 1 April 2012