Skip to content

Instantly share code, notes, and snippets.

@azuby
Created August 12, 2012 02:14
Show Gist options
  • Save azuby/3329023 to your computer and use it in GitHub Desktop.
Save azuby/3329023 to your computer and use it in GitHub Desktop.
HttpResponse response = null;
HttpEntity entity = null;
if (requestType.equalsIgnoreCase("get")) {
HttpGet httpGet = new HttpGet(url);
if (parameters != null) {
httpGet.setEntity(new UrlEncodedFormEntity(parameters));
}
httpGet.setHeader("Accept", acceptHeader);
response = httpClient.execute(httpGet);
} else if (requestType.equalsIgnoreCase("post")) {
HttpPost httpPost = new HttpPost(url);
if (parameters != null) {
httpPost.setEntity(new UrlEncodedFormEntity(parameters));
}
httpPost.setHeader("Accept", acceptHeader);
response = httpClient.execute(httpPost);
}
entity = response.getEntity();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment