Skip to content

Instantly share code, notes, and snippets.

@mryoshio
Created August 22, 2011 07:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mryoshio/1161827 to your computer and use it in GitHub Desktop.
Save mryoshio/1161827 to your computer and use it in GitHub Desktop.
build GET request using Apache HttpComponents
private HttpGet buildGetRequest(String _method, String _path, Map _params)
throws ServerConnectionException {
List params = new ArrayList();
for (Iterator it = _params.keySet().iterator(); it.hasNext();) {
String k = (String) it.next();
params.add(new BasicNameValuePair(k, (String) _params.get(k)));
}
HttpGet request = new HttpGet();
try {
request.setURI(URIUtils.createURI(scheme, host, port, _path,
URLEncodedUtils.format(params, "UTF-8"), null));
} catch (URISyntaxException e) {
throw new ServerConnectionException(e);
}
return request;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment