1 23 package org.archive.httpclient; 24 25 import java.io.IOException ; 26 import java.util.logging.Logger ; 27 28 import org.apache.commons.httpclient.HttpConnection; 29 import org.apache.commons.httpclient.HttpException; 30 import org.apache.commons.httpclient.HttpState; 31 import org.apache.commons.httpclient.methods.GetMethod; 32 import org.archive.util.HttpRecorder; 33 34 35 78 public class HttpRecorderGetMethod extends GetMethod { 79 80 protected static Logger logger = 81 Logger.getLogger(HttpRecorderGetMethod.class.getName()); 82 83 86 protected HttpRecorderMethod httpRecorderMethod = null; 87 88 89 public HttpRecorderGetMethod(String uri, HttpRecorder recorder) { 90 super(uri); 91 this.httpRecorderMethod = new HttpRecorderMethod(recorder); 92 } 93 94 protected void readResponseBody(HttpState state, HttpConnection connection) 95 throws IOException , HttpException { 96 this.httpRecorderMethod.markContentBegin(connection); 98 super.readResponseBody(state, connection); 99 } 100 101 protected boolean shouldCloseConnection(HttpConnection conn) { 102 return true; 106 } 107 108 public int execute(HttpState state, HttpConnection conn) 109 throws HttpException, IOException { 110 this.httpRecorderMethod.setConnection(conn); 116 return super.execute(state, conn); 117 } 118 119 protected void addProxyConnectionHeader(HttpState state, HttpConnection conn) 120 throws IOException , HttpException { 121 super.addProxyConnectionHeader(state, conn); 122 this.httpRecorderMethod.handleAddProxyConnectionHeader(this); 123 } 124 } 125 | Popular Tags |