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/12/19 21:40:00 UTC
svn commit: r357787 -
/jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java
Author: olegk
Date: Mon Dec 19 12:39:49 2005
New Revision: 357787
URL: http://svn.apache.org/viewcvs?rev=357787&view=rev
Log:
Deleted ResponseStrategy interface and its default impl
Modified:
jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java
Modified: jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java?rev=357787&r1=357786&r2=357787&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java (original)
+++ jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java Mon Dec 19 12:39:49 2005
@@ -72,8 +72,6 @@
import org.apache.http.coyote.params.CoyoteParams;
import org.apache.http.impl.ConnectionReuseStrategy;
import org.apache.http.impl.DefaultConnectionReuseStrategy;
-import org.apache.http.impl.DefaultResponseStrategy;
-import org.apache.http.impl.ResponseStrategy;
import org.apache.http.message.BasicHttpResponse;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.AbstractHttpProcessor;
@@ -397,6 +395,17 @@
}
}
+ private boolean canResponseHaveBody(final HttpRequest request, final HttpResponse response) {
+ if ("HEAD".equalsIgnoreCase(request.getRequestLine().getMethod())) {
+ return false;
+ }
+ int status = response.getStatusLine().getStatusCode();
+ return status >= HttpStatus.SC_OK
+ && status != HttpStatus.SC_NO_CONTENT
+ && status != HttpStatus.SC_NOT_MODIFIED
+ && status != HttpStatus.SC_RESET_CONTENT;
+ }
+
private void prepareHttpResponse() throws IOException {
this.coyotereq.getRequestProcessor().setStage(Constants.STAGE_ENDINPUT);
if (this.httpres != null) {
@@ -428,8 +437,7 @@
if (lang != null) {
tmp.setHeader(new Header("Content-Language", lang, false));
}
- ResponseStrategy responsestrategy = new DefaultResponseStrategy();
- if (responsestrategy.canHaveEntity(this.httpreq, this.httpres)) {
+ if (canResponseHaveBody(this.httpreq, this.httpres)) {
this.out = new CoyoteHttpEntity();
this.out.setContentLength(this.coyoteres.getContentLengthLong());
this.out.setContentType(this.coyoteres.getContentType());