@Test public void testExecute() throws IOException { AndroidHttpClient client = AndroidHttpClient.newInstance("foo"); FakeHttp.addPendingHttpResponse(200, "foo"); HttpResponse resp = client.execute(new HttpGet("/foo")); assertThat(resp.getStatusLine().getStatusCode()).isEqualTo(200); assertThat(CharStreams.toString(new InputStreamReader(resp.getEntity().getContent(), UTF_8))) .isEqualTo("foo"); } }
private String[] readUrl(String urlString) { InputStream in = null; BufferedReader reader=null; try { AndroidHttpClient client = AndroidHttpClient.newInstance(System.getProperty("http.agent")); HttpUriRequest request = new HttpGet(urlString); HttpResponse response = client.execute(request); reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8")); String json = readJSON(reader); client.close(); return parseJSON(json); } catch(IOException e) { e.printStackTrace(); } finally { closeStreams(in, reader); } return new String[0]; }
dumpRequestContent(request.getEntity().getContent()); if (DEBUG) Log.i(TAG, "Calling URL: " + request.getURI()); HttpResponse httpResponse = client.execute(request); if (DEBUG) Log.i(TAG, "Response: " + (httpResponse == null ? "null" : "length: " + httpResponse.toString().length())); if (httpResponse == null) {
dumpRequestContent(request.getEntity().getContent()); if (DEBUG) Log.i(TAG, "Calling URL: " + request.getURI()); HttpResponse httpResponse = client.execute(request); if (DEBUG) Log.i(TAG, "Response: " + (httpResponse == null ? "null" : "length: " + httpResponse.toString().length())); if (httpResponse == null) {
dumpRequestContent(request.getEntity().getContent()); if (DEBUG) Log.i(TAG, "Calling URL: " + request.getURI()); HttpResponse httpResponse = client.execute(request, localContext); if (DEBUG) Log.i(TAG, "Response: " + (httpResponse == null ? "null" : "length: " + httpResponse.toString().length())); if (DEBUG) Log.i(TAG, "Cookies: " + cookieStore.dump());
dumpRequestContent(request.getEntity().getContent()); if (DEBUG) Log.i(TAG, "Calling URL: " + request.getURI()); HttpResponse httpResponse = client.execute(request, localContext); if (DEBUG) Log.i(TAG, "Response: " + (httpResponse == null ? "null" : "length: " + httpResponse.toString().length())); if (DEBUG) Log.i(TAG, "Cookies: " + cookieStore.dump());
HttpContext localContext = new BasicHttpContext(); localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore); httpResponse = client.execute(request, localContext); if (DEBUG) Log.i(TAG, "Cookies: " + cookieStore.dump()); } else { if (DEBUG) Log.i(TAG, "Not using 4chan pass, executing with captcha"); httpResponse = client.execute(request);
HttpResponse response = client.execute(getRequest); final int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) {
LCTX.d(Thread.currentThread().getName() + ": Connecting to: " + req.getURI()); HttpResponse resp = client.execute(req); StatusLine statusLine = resp.getStatusLine(); int statusCode = statusLine.getStatusCode(); resp = client.execute(req); statusLine = resp.getStatusLine(); statusCode = statusLine.getStatusCode();
if (null == (response = client.execute(request))) { throw new InvocationException(target);
HttpResponse response = client.execute(target, req); StatusLine status = response.getStatusLine(); if (status.getStatusCode() != 200) { // HTTP 200 is success.