private HttpRequest signOutRequest(String token) { Map<String, String> formParameters = new HashMap<>(); if (token != null) { formParameters.put("token", token); } return HttpRequest.post(CONTAINER_URL + PATH + "out") .contentType("application/x-www-form-urlencoded") .form(formParameters); }
/** @see org.sonar.process.test.HttpProcess */ void kill() { try { HttpRequest.post("http://localhost:" + httpPort + "/" + "kill") .readTimeout(5000) .connectTimeout(5000) .ok(); } catch (Exception e) { // HTTP request can't be fully processed, as web server hardly // calls "System.exit()" } }
public void restart() { try { HttpRequest httpRequest = HttpRequest.post("http://localhost:" + httpPort + "/" + "restart") .readTimeout(5000) .connectTimeout(5000); if (!httpRequest.ok() || !"ok".equals(httpRequest.body())) { throw new IllegalStateException("Wrong response calling restart"); } } catch (Exception e) { throw new IllegalStateException("Failed to call restart", e); } }
protected String doInBackground(String... urls) { String response = null; try { String url = "http://" + urls[0] + "/index.php"; Log.d("myTag", url); response = HttpRequest.post(url).accept("application/json").form(userData).body(); Log.d("myTag", "Response-->" + response); } catch (HttpRequest.HttpRequestException exception) { Log.d("myTag", "HttpRequest Exception"); return null; } catch (Exception e) { e.printStackTrace(); return null; } return response; }
protected String doInBackground(String... urls) { String response = null; try { String url = "http://" + urls[0] + "/action.php"; Log.d("myTag", url); response = HttpRequest.post(url).accept("application/json").form(userData).body(); Log.d("myTag", "Response-->" + response); } catch (HttpRequest.HttpRequestException exception) { Log.d("myTag", "HttpRequest Exception"); Toast.makeText( getApplicationContext(), "GCM server registration failed", Toast.LENGTH_SHORT) .show(); return null; } catch (Exception e) { e.printStackTrace(); Toast.makeText( getApplicationContext(), "GCM server registration failed", Toast.LENGTH_SHORT) .show(); return null; } return response; }
private HttpRequest signInRequest(String emailValue, String passValue) { return HttpRequest.post(CONTAINER_URL + PATH + "in") .contentType("application/x-www-form-urlencoded") .form(getFormParameters(emailValue, passValue)); }