cvs commit: jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/server SimpleHttpServer.java SimpleHttpServerConnection.java

2004-05-11 Thread olegk
olegk   2004/05/11 13:43:55

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpConnection.java HttpMethod.java
HttpMethodBase.java
   httpclient/src/test/org/apache/commons/httpclient
TestNoHost.java
   httpclient/src/test/org/apache/commons/httpclient/server
SimpleHttpServer.java
SimpleHttpServerConnection.java
  Added:   httpclient/src/test/org/apache/commons/httpclient
TestMethodAbort.java
  Log:
  PR #20288 (httpMethod.abort needed)
  
  Added ability to abort the execution of HTTP methods
  
  Contributed by Oleg Kalnichevski
  Reviewed by Michael Becke
  
  Revision  ChangesPath
  1.90  +6 -4  
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java
  
  Index: HttpConnection.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java,v
  retrieving revision 1.89
  retrieving revision 1.90
  diff -u -r1.89 -r1.90
  --- HttpConnection.java   18 Apr 2004 23:51:34 -  1.89
  +++ HttpConnection.java   11 May 2004 20:43:54 -  1.90
  @@ -1035,6 +1035,8 @@
   /**
* Attempts to shutdown the [EMAIL PROTECTED] Socket}'s output, via 
Socket.shutdownOutput()
* when running on JVM 1.3 or higher.
  + * 
  + * @deprecated unused
*/
   public void shutdownOutput() {
   LOG.trace(enter HttpConnection.shutdownOutput());
  
  
  
  1.37  +12 -5 
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethod.java
  
  Index: HttpMethod.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethod.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- HttpMethod.java   18 Apr 2004 23:51:35 -  1.36
  +++ HttpMethod.java   11 May 2004 20:43:54 -  1.37
  @@ -33,7 +33,7 @@
   import java.io.InputStream;
   
   import org.apache.commons.httpclient.auth.AuthState;
  -import org.apache.commons.httpclient.params.*;
  +import org.apache.commons.httpclient.params.HttpMethodParams;
   
   /**
* p
  @@ -433,6 +433,13 @@
*/
   int execute(HttpState state, HttpConnection connection) 
   throws HttpException, IOException;
  +
  +/**
  + * Aborts the execution of the HTTP method.
  + * 
  + * @see #execute(HttpState, HttpConnection)
  + */
  +void abort();
   
   /**
* Recycles the HTTP method so that it can be used again.
  
  
  
  1.206 +39 -8 
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java
  
  Index: HttpMethodBase.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
  retrieving revision 1.205
  retrieving revision 1.206
  diff -u -r1.205 -r1.206
  --- HttpMethodBase.java   8 May 2004 10:12:07 -   1.205
  +++ HttpMethodBase.java   11 May 2004 20:43:54 -  1.206
  @@ -168,6 +168,9 @@
   /** HTTP protocol version used for execution of this method. */
   private HttpVersion effectiveVersion = null;
   
  +/** Whether the execution of this method has been aborted */
  +private transient boolean aborted = false;
  +
   // --- Constructors
   
   /**
  @@ -917,10 +920,9 @@
   if (conn == null) {
   throw new IllegalArgumentException(HttpConnection parameter may not be 
null);
   }
  -// TODO: do we care
  -//if (hasBeenUsed()) {
  -//throw new IllegalStateException(Already used, but not recycled.);
  -//}
  +if (this.aborted) {
  +throw new IllegalStateException(Method has been aborted);
  +}
   if (!validate()) {
   throw new ProtocolException(HttpMethodBase object not valid);
   }
  @@ -974,6 +976,21 @@
   }
   
   /**
  + * Aborts the execution of this method.
  + */
  +
  +public void abort() {
  +if (this.aborted) {
  +return;
  +}
  +this.aborted = true;
  +HttpConnection conn = this.responseConnection; 
  +if (conn != null) {
  +conn.close();
  +}
  +}
  +
  +/**
* Returns tttrue/tt if the HTTP method has been already [EMAIL PROTECTED] 
#execute executed},
* but not [EMAIL PROTECTED] #recycle recycled}.
* 
  @@ -1004,6 +1021,8 @@
   getResponseHeaderGroup().clear();
   getResponseTrailerHeaderGroup().clear();
   statusLine 

cvs commit: jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/server SimpleHttpServer.java SimpleHttpServerConnection.java

2003-11-18 Thread mbecke
mbecke  2003/11/18 16:23:30

  Modified:httpclient/src/test/org/apache/commons/httpclient/server
Tag: HTTPCLIENT_2_0_BRANCH SimpleHttpServer.java
SimpleHttpServerConnection.java
  Log:
  Fixed pre 1.4 compile errors.
  
  Revision  ChangesPath
  No   revision
  No   revision
  1.1.2.2   +14 -11
jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/server/Attic/SimpleHttpServer.java
  
  Index: SimpleHttpServer.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/server/Attic/SimpleHttpServer.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- SimpleHttpServer.java 18 Nov 2003 12:26:38 -  1.1.2.1
  +++ SimpleHttpServer.java 19 Nov 2003 00:23:30 -  1.1.2.2
  @@ -82,7 +82,7 @@
* @author Christian Kohlschuetter
*/
   public class SimpleHttpServer implements Runnable {
  -private static final Log log = LogFactory.getLog(SimpleHttpServer.class);
  +private static final Log LOG = LogFactory.getLog(SimpleHttpServer.class);
   
   private ServerSocket server = null;
   private Thread t;
  @@ -110,8 +110,8 @@
*/
   public SimpleHttpServer(int port) throws IOException {
   server = new ServerSocket(port);
  -if(log.isInfoEnabled()) {
  -log.info(New SimpleHttpServer on port  + getLocalPort());
  +if(LOG.isInfoEnabled()) {
  +LOG.info(New SimpleHttpServer on port  + getLocalPort());
   }
   tg = new ThreadGroup(SimpleHttpServer group);
   t = new Thread(tg, this, SimpleHttpServer connection handler);
  @@ -149,8 +149,8 @@
   }
   
   stopped = true;
  -if(log.isInfoEnabled()) {
  -log.info(Stopping SimpleHttpServer on port  + getLocalPort());
  +if(LOG.isInfoEnabled()) {
  +LOG.info(Stopping SimpleHttpServer on port  + getLocalPort());
   }
   
   tg.interrupt();
  @@ -225,17 +225,20 @@
   t.setDaemon(true);
   t.start();
   } catch (IOException e) {
  -throw new RuntimeException(e);
  +LOG.error(SimpleHttpServer error, e);
  +throw new RuntimeException(e.getMessage());
   }
   Thread.sleep(100);
   }
   } catch (InterruptedException accept) {
   } catch (SocketException e) {
   if (!stopped) {
  -throw new RuntimeException(e);
  +LOG.error(SimpleHttpServer error, e);
  +throw new RuntimeException(e.getMessage());
   }
   } catch (IOException e) {
  -throw new RuntimeException(e);
  +LOG.error(SimpleHttpServer error, e);
  +throw new RuntimeException(e.getMessage());
   } finally {
   destroy();
   }
  
  
  
  1.1.2.2   +10 -4 
jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/server/Attic/SimpleHttpServerConnection.java
  
  Index: SimpleHttpServerConnection.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/server/Attic/SimpleHttpServerConnection.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- SimpleHttpServerConnection.java   18 Nov 2003 12:26:38 -  1.1.2.1
  +++ SimpleHttpServerConnection.java   19 Nov 2003 00:23:30 -  1.1.2.2
  @@ -71,6 +71,8 @@
   import org.apache.commons.httpclient.Header;
   import org.apache.commons.httpclient.HttpParser;
   import org.apache.commons.httpclient.HttpStatus;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   
   /**
* A connection to the SimpleHttpServer. 
  @@ -78,6 +80,9 @@
* @author Christian Kohlschuetter
*/
   public class SimpleHttpServerConnection implements Runnable {
  +
  +private static final Log LOG = 
LogFactory.getLog(SimpleHttpServerConnection.class);
  +
   private SimpleHttpServer server;
   private Socket socket;
   private InputStream in;
  @@ -120,7 +125,8 @@
   } while(keepAlive);
   } catch (SocketException ignore) {
   } catch (IOException e) {
  -throw new RuntimeException(e);
  +LOG.error(ServerConnection read error, e);
  +throw new RuntimeException(e.getMessage());
   } finally {
   destroy();
   }
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]