hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1720945 - in /httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http: ./ impl/ impl/io/ impl/nio/
Date Sat, 19 Dec 2015 16:50:13 GMT
Author: ggregory
Date: Sat Dec 19 16:50:13 2015
New Revision: 1720945

URL: http://svn.apache.org/viewvc?rev=1720945&view=rev
Log:
Add constants to HttpStatus to denote classes of statuses for 1xx, 2xx, 3xx, 4xx, and 5xx
and start using these.

Modified:
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/HttpStatus.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/DefaultConnectionReuseStrategy.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnection.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/io/HttpRequestExecutor.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/io/HttpService.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultNHttpClientConnection.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultNHttpServerConnection.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/nio/HttpAsyncRequestExecutor.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/nio/HttpAsyncService.java

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/HttpStatus.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/HttpStatus.java?rev=1720945&r1=1720944&r2=1720945&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/HttpStatus.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/HttpStatus.java
Sat Dec 19 16:50:13 2015
@@ -39,6 +39,8 @@ package org.apache.hc.core5.http;
 public interface HttpStatus {
 
     // --- 1xx Informational ---
+    /** {@code 100 1xx Informational} (HTTP/1.1 - RFC 2616) */
+    public static final int SC_INFORMATIONAL = 100;
 
     /** {@code 100 Continue} (HTTP/1.1 - RFC 2616) */
     public static final int SC_CONTINUE = 100;
@@ -48,6 +50,8 @@ public interface HttpStatus {
     public static final int SC_PROCESSING = 102;
 
     // --- 2xx Success ---
+    /** {@code 2xx Success} (HTTP/1.0 - RFC 1945) */
+    public static final int SC_SUCCESS = 200;
 
     /** {@code 200 OK} (HTTP/1.0 - RFC 1945) */
     public static final int SC_OK = 200;
@@ -71,6 +75,8 @@ public interface HttpStatus {
     public static final int SC_MULTI_STATUS = 207;
 
     // --- 3xx Redirection ---
+    /** {@code 3xx Redirection} (HTTP/1.1 - RFC 2616) */
+    public static final int SC_REDIRECTION = 300;
 
     /** {@code 300 Mutliple Choices} (HTTP/1.1 - RFC 2616) */
     public static final int SC_MULTIPLE_CHOICES = 300;
@@ -88,6 +94,8 @@ public interface HttpStatus {
     public static final int SC_TEMPORARY_REDIRECT = 307;
 
     // --- 4xx Client Error ---
+    /** {@code 4xx Client Error} (HTTP/1.1 - RFC 2616) */
+    public static final int SC_CLIENT_ERROR = 400;
 
     /** {@code 400 Bad Request} (HTTP/1.1 - RFC 2616) */
     public static final int SC_BAD_REQUEST = 400;
@@ -156,8 +164,10 @@ public interface HttpStatus {
     public static final int SC_FAILED_DEPENDENCY = 424;
 
     // --- 5xx Server Error ---
-
     /** {@code 500 Server Error} (HTTP/1.0 - RFC 1945) */
+    public static final int SC_SERVER_ERROR = 500;
+
+    /** {@code 500 Internal Server Error} (HTTP/1.0 - RFC 1945) */
     public static final int SC_INTERNAL_SERVER_ERROR = 500;
     /** {@code 501 Not Implemented} (HTTP/1.0 - RFC 1945) */
     public static final int SC_NOT_IMPLEMENTED = 501;

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/DefaultConnectionReuseStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/DefaultConnectionReuseStrategy.java?rev=1720945&r1=1720944&r2=1720945&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/DefaultConnectionReuseStrategy.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/DefaultConnectionReuseStrategy.java
Sat Dec 19 16:50:13 2015
@@ -141,7 +141,7 @@ public class DefaultConnectionReuseStrat
 
     private boolean canResponseHaveBody(final HttpResponse response) {
         final int status = response.getStatusLine().getStatusCode();
-        return status >= HttpStatus.SC_OK
+        return status >= HttpStatus.SC_SUCCESS
             && status != HttpStatus.SC_NO_CONTENT
             && status != HttpStatus.SC_NOT_MODIFIED
             && status != HttpStatus.SC_RESET_CONTENT;

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java?rev=1720945&r1=1720944&r2=1720945&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java
Sat Dec 19 16:50:13 2015
@@ -188,7 +188,7 @@ public class DefaultBHttpClientConnectio
         ensureOpen();
         final HttpResponse response = this.responseParser.parse(this.inbuffer);
         onResponseReceived(response);
-        if (response.getStatusLine().getStatusCode() >= HttpStatus.SC_OK) {
+        if (response.getStatusLine().getStatusCode() >= HttpStatus.SC_SUCCESS) {
             incrementResponseCount();
         }
         return response;

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnection.java?rev=1720945&r1=1720944&r2=1720945&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnection.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnection.java
Sat Dec 19 16:50:13 2015
@@ -158,7 +158,7 @@ public class DefaultBHttpServerConnectio
         ensureOpen();
         this.responseWriter.write(response, this.outbuffer);
         onResponseSubmitted(response);
-        if (response.getStatusLine().getStatusCode() >= HttpStatus.SC_OK) {
+        if (response.getStatusLine().getStatusCode() >= HttpStatus.SC_SUCCESS) {
             incrementResponseCount();
         }
     }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/io/HttpRequestExecutor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/io/HttpRequestExecutor.java?rev=1720945&r1=1720944&r2=1720945&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/io/HttpRequestExecutor.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/io/HttpRequestExecutor.java
Sat Dec 19 16:50:13 2015
@@ -96,7 +96,7 @@ public class HttpRequestExecutor {
             return false;
         }
         final int status = response.getStatusLine().getStatusCode();
-        return status >= HttpStatus.SC_OK
+        return status >= HttpStatus.SC_SUCCESS
             && status != HttpStatus.SC_NO_CONTENT
             && status != HttpStatus.SC_NOT_MODIFIED
             && status != HttpStatus.SC_RESET_CONTENT;
@@ -143,7 +143,7 @@ public class HttpRequestExecutor {
                     if (conn.isDataAvailable(this.waitForContinue)) {
                         response = conn.receiveResponseHeader();
                         final int status = response.getStatusLine().getStatusCode();
-                        if (status < HttpStatus.SC_OK) {
+                        if (status < HttpStatus.SC_SUCCESS) {
                             if (status != HttpStatus.SC_CONTINUE) {
                                 throw new ProtocolException("Unexpected response: " + response.getStatusLine());
                             }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/io/HttpService.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/io/HttpService.java?rev=1720945&r1=1720944&r2=1720945&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/io/HttpService.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/io/HttpService.java
Sat Dec 19 16:50:13 2015
@@ -180,7 +180,7 @@ public class HttpService {
                     handleException(ex, response);
                 }
             }
-            if (response.getStatusLine().getStatusCode() < HttpStatus.SC_OK) {
+            if (response.getStatusLine().getStatusCode() < HttpStatus.SC_SUCCESS) {
                 // Send 1xx response indicating the server expectations
                 // have been met
                 conn.sendResponseHeader(response);
@@ -239,7 +239,7 @@ public class HttpService {
             return false;
         }
         final int status = response.getStatusLine().getStatusCode();
-        return status >= HttpStatus.SC_OK
+        return status >= HttpStatus.SC_SUCCESS
                 && status != HttpStatus.SC_NO_CONTENT
                 && status != HttpStatus.SC_NOT_MODIFIED
                 && status != HttpStatus.SC_RESET_CONTENT;

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultNHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultNHttpClientConnection.java?rev=1720945&r1=1720944&r2=1720945&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultNHttpClientConnection.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultNHttpClientConnection.java
Sat Dec 19 16:50:13 2015
@@ -176,7 +176,7 @@ public class DefaultNHttpClientConnectio
                     this.response = this.responseParser.parse(this.inbuf, bytesRead == -1);
                 } while (bytesRead > 0 && this.response == null);
                 if (this.response != null) {
-                    if (this.response.getStatusLine().getStatusCode() >= HttpStatus.SC_OK)
{
+                    if (this.response.getStatusLine().getStatusCode() >= HttpStatus.SC_SUCCESS)
{
                         final long len = this.incomingContentStrategy.determineLength(this.response);
                         if (len != ContentLengthStrategy.UNDEFINED) {
                             this.contentDecoder = createContentDecoder(

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultNHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultNHttpServerConnection.java?rev=1720945&r1=1720944&r2=1720945&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultNHttpServerConnection.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultNHttpServerConnection.java
Sat Dec 19 16:50:13 2015
@@ -266,7 +266,7 @@ public class DefaultNHttpServerConnectio
         this.responseWriter.write(response, this.outbuf);
         this.hasBufferedOutput = this.outbuf.hasData();
 
-        if (response.getStatusLine().getStatusCode() >= HttpStatus.SC_OK) {
+        if (response.getStatusLine().getStatusCode() >= HttpStatus.SC_SUCCESS) {
             this.connMetrics.incrementResponseCount();
             final HttpEntity entity = response.getEntity();
             if (entity != null) {

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/nio/HttpAsyncRequestExecutor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/nio/HttpAsyncRequestExecutor.java?rev=1720945&r1=1720944&r2=1720945&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/nio/HttpAsyncRequestExecutor.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/nio/HttpAsyncRequestExecutor.java
Sat Dec 19 16:50:13 2015
@@ -521,10 +521,10 @@ public class HttpAsyncRequestExecutor im
         if (method.equalsIgnoreCase("HEAD")) {
             return false;
         }
-        if (method.equalsIgnoreCase("CONNECT") && status < 300) {
+        if (method.equalsIgnoreCase("CONNECT") && status < HttpStatus.SC_REDIRECTION)
{
             return false;
         }
-        return status >= HttpStatus.SC_OK
+        return status >= HttpStatus.SC_SUCCESS
             && status != HttpStatus.SC_NO_CONTENT
             && status != HttpStatus.SC_NOT_MODIFIED
             && status != HttpStatus.SC_RESET_CONTENT;

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/nio/HttpAsyncService.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/nio/HttpAsyncService.java?rev=1720945&r1=1720944&r2=1720945&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/nio/HttpAsyncService.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/hc/core5/http/impl/nio/HttpAsyncService.java
Sat Dec 19 16:50:13 2015
@@ -604,7 +604,7 @@ public class HttpAsyncService implements
             return false;
         }
         final int status = response.getStatusLine().getStatusCode();
-        return status >= HttpStatus.SC_OK
+        return status >= HttpStatus.SC_SUCCESS
             && status != HttpStatus.SC_NO_CONTENT
             && status != HttpStatus.SC_NOT_MODIFIED
             && status != HttpStatus.SC_RESET_CONTENT;
@@ -966,7 +966,7 @@ public class HttpAsyncService implements
 
                 // If there is an incoming request associated with the exchange
                 // the response will be sent early (out of sequence).
-                if (response.getStatusLine().getStatusCode() >= HttpStatus.SC_OK &&
this.incoming != null) {
+                if (response.getStatusLine().getStatusCode() >= HttpStatus.SC_SUCCESS
&& this.incoming != null) {
                     this.incoming.setEarlyResponse(true);
                 }
 



Mime
View raw message