Note that there are some explanatory texts on larger screens.

plurals
  1. POHttp Post and network delay
    primarykey
    data
    text
    <p>I need to make about 15 calls to diferent web services (php) at the application startup.</p> <p>I'm using the following code for the post</p> <pre><code>public static String post(String url, List&lt;BasicNameValuePair&gt; postvalues, HttpClient httpclient) { try { if (httpclient == null) { httpclient = new DefaultHttpClient(); } HttpPost httppost = new HttpPost(url); if ((postvalues == null)) { postvalues = new ArrayList&lt;BasicNameValuePair&gt;(); } httppost.setEntity(new UrlEncodedFormEntity(postvalues, "UTF-8")); // Execute HTTP Post Request HttpResponse response = httpclient.execute(httppost); return requestToString(response); } catch (Exception e) { e.printStackTrace(); return null; } } private static String requestToString(HttpResponse response) { String result = ""; try { InputStream in = response.getEntity().getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); StringBuilder str = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { str.append(line + "\n"); } in.close(); result = str.toString(); } catch (Exception ex) { result = "Error"; } return result; } </code></pre> <p>The problem is that some of the petitions must be requested in a given order and each request takes about 1-2 second so the "Loading splash" takes about 10 seconds.</p> <p>So my question is:Since all the connections are to the same server, how can I improve this delay? Is there some way of open a connection and send all the petitions through that "tunnel" reducing the delay?</p> <p>NOTE: I tested the code and the requests take the same time reusing the httpclient using a new one in each connection</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload