Created
November 5, 2012 11:01
-
-
Save pwntester/4016639 to your computer and use it in GitHub Desktop.
executeRequest
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 void executeRequest(HttpUriRequest request, String url, | |
Context context) { | |
HttpClient client = CustomSSLSocketFactory.getNewHttpClient(); | |
HashMap<String, String> proxyInfo = Utils.getProxyMap(context); | |
String proxyHost = proxyInfo.get("proxyHost"); | |
String proxyPort = proxyInfo.get("proxyPort"); | |
if (!(proxyHost.equals("") || proxyPort.equals(""))) { | |
HttpHost proxy = new HttpHost(proxyHost, | |
Integer.parseInt(proxyPort)); | |
client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, | |
proxy); | |
} | |
HttpResponse httpResponse; | |
try { | |
httpResponse = client.execute(request); | |
responseCode = httpResponse.getStatusLine().getStatusCode(); | |
message = httpResponse.getStatusLine().getReasonPhrase(); | |
HttpEntity entity = httpResponse.getEntity(); | |
if (entity != null) { | |
InputStream instream = entity.getContent(); | |
response = convertStreamToString(instream); | |
// Closing the input stream will trigger connection release | |
instream.close(); | |
} | |
} catch (ClientProtocolException e) { | |
client.getConnectionManager().shutdown(); | |
} catch (IOException e) { | |
client.getConnectionManager().shutdown(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment