/** * Create a request, add headers, and content, * then send to HTTPSession to do the bulk of the work. * * @return statuscode */ public int execute() throws HTTPException { HttpResponse res = executeRaw(); if(res != null) return res.getStatusLine().getStatusCode(); else throw new HTTPException("HTTPMethod.execute: null response"); }
/** * Test that a large number of open/close does not lose connections; * check for null response. * This test uses an implicit HTTPSession. */ @Test public void testClosing2() throws HTTPException { // Set max # of connections HTTPSession.setGlobalMaxConnections(201); for(int i = 0; i < 200; i++) { HTTPMethod m = HTTPFactory.Get(CLOSEFILE); HttpResponse res = null; try { res = m.executeRaw(); } catch (HTTPException e) { if(e.getCause() instanceof ConnectionPoolTimeoutException) { System.err.println("TestMisc: timeout: " + i); } else throw e; } Assert.assertFalse("Null response", res == null); m.close(); } } }