You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2005/04/03 18:20:22 UTC
svn commit: r159932 -
jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultResponseConsumedWatcher.java
Author: olegk
Date: Sun Apr 3 09:20:21 2005
New Revision: 159932
URL: http://svn.apache.org/viewcvs?view=rev&rev=159932
Log:
Added default impl of ResponseConsumedWatcher interface
Added:
jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultResponseConsumedWatcher.java (with props)
Added: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultResponseConsumedWatcher.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultResponseConsumedWatcher.java?view=auto&rev=159932
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultResponseConsumedWatcher.java (added)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultResponseConsumedWatcher.java Sun Apr 3 09:20:21 2005
@@ -0,0 +1,76 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.impl;
+
+import java.io.IOException;
+
+import org.apache.http.HttpConnection;
+import org.apache.http.HttpResponse;
+
+/**
+ * <p>
+ * </p>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ *
+ * @since 4.0
+ */
+public class DefaultResponseConsumedWatcher
+ implements ResponseConsumedWatcher {
+
+ private final HttpConnection conn;
+ private final HttpResponse response;
+
+ public DefaultResponseConsumedWatcher(
+ final HttpConnection conn, final HttpResponse response) {
+ super();
+ if (conn == null) {
+ throw new IllegalArgumentException("HTTP connection may not be null");
+ }
+ if (response == null) {
+ throw new IllegalArgumentException("HTTP response may not be null");
+ }
+ this.conn = conn;
+ this.response = response;
+ }
+
+ public void responseConsumed() {
+ ConnectionReuseStrategy s = new DefaultConnectionReuseStrategy();
+ if (!s.keepAlive(this.response)) {
+ try {
+ this.conn.close();
+ } catch (IOException ex) {
+ // log error
+ }
+ }
+ }
+
+}
Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultResponseConsumedWatcher.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultResponseConsumedWatcher.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultResponseConsumedWatcher.java
------------------------------------------------------------------------------
svn:mime-type = text/plain