1 23 package org.archive.httpclient; 24 25 import java.util.logging.Logger ; 26 27 import org.apache.commons.httpclient.Header; 28 import org.apache.commons.httpclient.HttpConnection; 29 import org.apache.commons.httpclient.HttpMethod; 30 import org.archive.util.HttpRecorder; 31 32 33 42 public class HttpRecorderMethod { 43 protected static Logger logger = 44 Logger.getLogger(HttpRecorderMethod.class.getName()); 45 46 49 private HttpRecorder httpRecorder = null; 50 51 57 private HttpConnection connection = null; 58 59 60 public HttpRecorderMethod(HttpRecorder recorder) { 61 this.httpRecorder = recorder; 62 } 63 64 public void markContentBegin(HttpConnection c) { 65 if (c != this.connection) { 66 throw new IllegalArgumentException ("Connections differ: " + 70 this.connection + " " + c + " " + 71 Thread.currentThread().getName()); 72 } 73 this.httpRecorder.markContentBegin(); 74 } 75 76 79 public HttpConnection getConnection() { 80 return this.connection; 81 } 82 83 86 public void setConnection(HttpConnection connection) { 87 this.connection = connection; 88 } 89 92 public HttpRecorder getHttpRecorder() { 93 return httpRecorder; 94 } 95 96 104 public void handleAddProxyConnectionHeader(HttpMethod method) { 105 Header h = method.getRequestHeader("Proxy-Connection"); 106 if (h != null) { 107 h.setValue("close"); 108 method.setRequestHeader(h); 109 } 110 } 111 } 112 | Popular Tags |