Author: markt Date: Wed Apr 6 15:18:26 2011 New Revision: 1089488 URL: http://svn.apache.org/viewvc?rev=1089488&view=rev Log: Refactor to (hopefully) allow unit testing of pipelining support
Modified: tomcat/trunk/test/org/apache/catalina/startup/SimpleHttpClient.java Modified: tomcat/trunk/test/org/apache/catalina/startup/SimpleHttpClient.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/startup/SimpleHttpClient.java?rev=1089488&r1=1089487&r2=1089488&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/catalina/startup/SimpleHttpClient.java (original) +++ tomcat/trunk/test/org/apache/catalina/startup/SimpleHttpClient.java Wed Apr 6 15:18:26 2011 @@ -35,8 +35,7 @@ import java.util.List; /** * Simple client for unit testing. It isn't robust, it isn't secure and * should not be used as the basis for production code. Its only purpose - * is to do the bare minimum for the unit tests. It does not support keep-alive - * connections - make sure you send a Connection: close header with the request. + * is to do the bare minimum for the unit tests. */ public abstract class SimpleHttpClient { public static final String TEMP_DIR = @@ -130,7 +129,15 @@ public abstract class SimpleHttpClient { public void processRequest() throws IOException, InterruptedException { processRequest(true); } + public void processRequest(boolean readBody) throws IOException, InterruptedException { + sendRequest(); + + readResponse(readBody); + + } + + public void sendRequest() throws InterruptedException, IOException { // Send the request boolean first = true; for (String requestPart : request) { @@ -142,6 +149,13 @@ public abstract class SimpleHttpClient { writer.write(requestPart); writer.flush(); } + } + + public void readResponse(boolean readBody) throws IOException { + // Reset fields use to hold response + responseLine = null; + responseHeaders.clear(); + responseBody = null; // Read the response responseLine = readLine(); @@ -175,7 +189,6 @@ public abstract class SimpleHttpClient { } } responseBody = builder.toString(); - } public String readLine() throws IOException { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org