protected HttpURLConnection openConnection ( final URL url , final RpcRequest request ) throws IOException { HttpURLConnection connection = ( HttpURLConnection ) url . openConnection ( ) ; if ( request . isPost ( ) ) { connection . setRequestMethod ( POST ) ; connection . setRequestProperty ( CONTENT_TYPE_HEADER , APPLICATION_X_WWW_FORM_URLENCODED ) ; connection . setDoOutput ( true ) ; } else { connection . setRequestMethod ( GET ) ; } return connection ; }
Opens a connection and sets its HTTP method .