From 46b5b099298a430a6fa4150d32ba098561798c68 Mon Sep 17 00:00:00 2001 From: markt Date: Wed, 6 Apr 2011 15:18:26 +0000 Subject: [PATCH] Refactor to (hopefully) allow unit testing of pipelining support git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1089488 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/catalina/startup/SimpleHttpClient.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/test/org/apache/catalina/startup/SimpleHttpClient.java b/test/org/apache/catalina/startup/SimpleHttpClient.java index 119b6958a..88ed4235f 100644 --- a/test/org/apache/catalina/startup/SimpleHttpClient.java +++ b/test/org/apache/catalina/startup/SimpleHttpClient.java @@ -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 { -- 2.11.0