List<String> reply = new ArrayList<String>();
BufferedReader response = null;
try {
- response = HttpClientUtils.doHttpUrlPost(restUrl,
- commands);
+ response = HttpClientUtils
+ .doHttpUrlPost(restUrl, commands, 100, 2000);
String line = "";
while ((line = response.readLine()) != null) {
reply.add(line);
import java.io.StringReader;
import java.net.URL;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.apache.http.message.BasicNameValuePair;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
-import org.json.simple.JSONStreamAware;
import org.json.simple.parser.ContentHandler;
import org.json.simple.parser.ParseException;
// return processJsonResponseFor(HttpClientUtils.doHttpUrlPost(twoDtoolsURL,
// vals));
ArrayList<Reader> readers = new ArrayList<Reader>();
- readers.add(HttpClientUtils.doHttpUrlPost(twoDtoolsURL, vals));
+ readers.add(HttpClientUtils.doHttpUrlPost(twoDtoolsURL, vals, 0, 0));
return readers.iterator();
}
StringBuilder command = new StringBuilder(32);
if (lastMousedOverAtomSpec != null)
{
- command.append("~select " + lastMousedOverAtomSpec + ";");
+ command.append("~show " + lastMousedOverAtomSpec + ";");
}
viewerCommandHistory(false);
+ command.append("show ").append(atomSpec);
String cmd = command.toString();
- cmd = "select " + atomSpec;
if (cmd.length() > 0)
{
viewer.sendChimeraCommand(cmd, false);
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.CoreProtocolPNames;
+import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
/**
* @throws Exception
*/
public static BufferedReader doHttpUrlPost(String postUrl,
- List<NameValuePair> vals) throws ClientProtocolException,
+ List<NameValuePair> vals, int connectionTimeoutMs,
+ int readTimeoutMs) throws ClientProtocolException,
IOException
{
+ // todo use HttpClient 4.3 or later and class RequestConfig
HttpParams params = new BasicHttpParams();
params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION,
HttpVersion.HTTP_1_1);
+ if (connectionTimeoutMs > 0)
+ {
+ HttpConnectionParams
+ .setConnectionTimeout(params, connectionTimeoutMs);
+ }
+ if (readTimeoutMs > 0)
+ {
+ HttpConnectionParams.setSoTimeout(params, readTimeoutMs);
+ }
HttpClient httpclient = new DefaultHttpClient(params);
HttpPost httppost = new HttpPost(postUrl);
UrlEncodedFormEntity ue = new UrlEncodedFormEntity(vals, "UTF-8");