Created
August 22, 2011 07:00
-
-
Save mryoshio/1161827 to your computer and use it in GitHub Desktop.
build GET request using Apache HttpComponents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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