hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1520019 - in /httpcomponents/httpcore/trunk: ./ httpcore/src/main/java/org/apache/http/ httpcore/src/main/java/org/apache/http/impl/ httpcore/src/main/java/org/apache/http/message/ httpcore/src/test/java/org/apache/http/message/
Date Wed, 04 Sep 2013 13:35:16 GMT
Author: olegk
Date: Wed Sep  4 13:35:16 2013
New Revision: 1520019

URL: http://svn.apache.org/r1520019
Log:
HTTPCORE-347: (Regression) HttpResponse#setStatusCode() does not update reason phrase

Modified:
    httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/HttpResponse.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/ReasonPhraseCatalog.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpResponseFactory.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHttpResponse.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicHttpResponse.java

Modified: httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt?rev=1520019&r1=1520018&r2=1520019&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpcore/trunk/RELEASE_NOTES.txt Wed Sep  4 13:35:16 2013
@@ -1,3 +1,11 @@
+Changes since 4.3
+-------------------
+
+* [HTTPCORE-347] (Regression) HttpResponse#setStatusCode() does not update reason phrase.
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
+
+
 Release 4.3
 -------------------
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/HttpResponse.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/HttpResponse.java?rev=1520019&r1=1520018&r2=1520019&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/HttpResponse.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/HttpResponse.java
Wed Sep  4 13:35:16 2013
@@ -83,8 +83,6 @@ public interface HttpResponse extends Ht
 
     /**
      * Updates the status line of this response with a new status code.
-     * The status line can only be updated if it is available. It must
-     * have been set either explicitly or in a constructor.
      *
      * @param code the HTTP status code.
      *
@@ -100,8 +98,6 @@ public interface HttpResponse extends Ht
 
     /**
      * Updates the status line of this response with a new reason phrase.
-     * The status line can only be updated if it is available. It must
-     * have been set either explicitly or in a constructor.
      *
      * @param reason    the new reason phrase as a single-line string, or
      *                  <code>null</code> to unset the reason phrase
@@ -146,22 +142,14 @@ public interface HttpResponse extends Ht
      * It can be changed using {@link #setLocale setLocale}.
      *
      * @return  the locale of this response, never <code>null</code>
-     *
-     * @deprecated (4.3) use {@link org.apache.http.impl.DefaultHttpRequestFactory}
      */
-    @Deprecated
     Locale getLocale();
 
     /**
      * Changes the locale of this response.
-     * If there is a status line, it's reason phrase will be updated
-     * according to the status code and new locale.
      *
      * @param loc       the new locale
-     *
-     * @deprecated (4.3) use {@link org.apache.http.impl.DefaultHttpRequestFactory}
      */
-    @Deprecated
     void setLocale(Locale loc);
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/ReasonPhraseCatalog.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/ReasonPhraseCatalog.java?rev=1520019&r1=1520018&r2=1520019&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/ReasonPhraseCatalog.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/ReasonPhraseCatalog.java
Wed Sep  4 13:35:16 2013
@@ -46,6 +46,6 @@ public interface ReasonPhraseCatalog {
      *
      * @return  the reason phrase, or <code>null</code> if unknown
      */
-    public String getReason(int status, Locale loc);
+    String getReason(int status, Locale loc);
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpResponseFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpResponseFactory.java?rev=1520019&r1=1520018&r2=1520019&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpResponseFactory.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpResponseFactory.java
Wed Sep  4 13:35:16 2013
@@ -79,9 +79,9 @@ public class DefaultHttpResponseFactory 
             final HttpContext context) {
         Args.notNull(ver, "HTTP version");
         final Locale loc = determineLocale(context);
-        final String reason   = reasonCatalog.getReason(status, loc);
+        final String reason   = this.reasonCatalog.getReason(status, loc);
         final StatusLine statusline = new BasicStatusLine(ver, status, reason);
-        return new BasicHttpResponse(statusline);
+        return new BasicHttpResponse(statusline, this.reasonCatalog, loc);
     }
 
 
@@ -90,7 +90,7 @@ public class DefaultHttpResponseFactory 
             final StatusLine statusline,
             final HttpContext context) {
         Args.notNull(statusline, "Status line");
-        return new BasicHttpResponse(statusline);
+        return new BasicHttpResponse(statusline, this.reasonCatalog, determineLocale(context));
     }
 
     /**

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHttpResponse.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHttpResponse.java?rev=1520019&r1=1520018&r2=1520019&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHttpResponse.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHttpResponse.java
Wed Sep  4 13:35:16 2013
@@ -66,10 +66,7 @@ public class BasicHttpResponse extends A
      *                          reason phrase lookup
      * @param locale            the locale for looking up reason phrases, or
      *                          <code>null</code> for the system locale
-     *
-     * @deprecated (4.3) use {@link org.apache.http.impl.DefaultHttpResponseFactory}
      */
-    @Deprecated
     public BasicHttpResponse(final StatusLine statusline,
                              final ReasonPhraseCatalog catalog,
                              final Locale locale) {
@@ -134,7 +131,7 @@ public class BasicHttpResponse extends A
             this.statusline = new BasicStatusLine(
                     this.ver != null ? this.ver : HttpVersion.HTTP_1_1,
                     this.code,
-                    this.reasonPhrase);
+                    this.reasonPhrase != null ? this.reasonPhrase : getReason(this.code));
         }
         return this.statusline;
     }
@@ -144,10 +141,6 @@ public class BasicHttpResponse extends A
         return this.entity;
     }
 
-    /**
-     * @deprecated (4.3) use {@link org.apache.http.impl.DefaultHttpRequestFactory}
-     */
-    @Deprecated
     public Locale getLocale() {
         return this.locale;
     }
@@ -184,6 +177,7 @@ public class BasicHttpResponse extends A
         Args.notNegative(code, "Status code");
         this.statusline = null;
         this.code = code;
+        this.reasonPhrase = null;
     }
 
     // non-javadoc, see interface HttpResponse
@@ -197,10 +191,6 @@ public class BasicHttpResponse extends A
         this.entity = entity;
     }
 
-    /**
-     * @deprecated (4.3) use {@link org.apache.http.impl.DefaultHttpRequestFactory}
-     */
-    @Deprecated
     public void setLocale(final Locale locale) {
         this.locale =  Args.notNull(locale, "Locale");
         this.statusline = null;
@@ -214,10 +204,7 @@ public class BasicHttpResponse extends A
      * @param code      the status code for which to look up the reason
      *
      * @return  the reason phrase, or <code>null</code> if there is none
-     *
-     * @deprecated (4.3) use {@link org.apache.http.impl.DefaultHttpRequestFactory}
      */
-    @Deprecated
     protected String getReason(final int code) {
         return this.reasonCatalog != null ? this.reasonCatalog.getReason(code,
                 this.locale != null ? this.locale : Locale.getDefault()) : null;

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicHttpResponse.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicHttpResponse.java?rev=1520019&r1=1520018&r2=1520019&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicHttpResponse.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicHttpResponse.java
Wed Sep  4 13:35:16 2013
@@ -58,7 +58,7 @@ public class TestBasicHttpResponse {
         response.setStatusCode(299);
         Assert.assertEquals(HttpVersion.HTTP_1_1, response.getStatusLine().getProtocolVersion());
         Assert.assertEquals(299, response.getStatusLine().getStatusCode());
-        Assert.assertEquals("Kind of OK", response.getStatusLine().getReasonPhrase());
+        Assert.assertEquals(null, response.getStatusLine().getReasonPhrase());
         response.setStatusLine(HttpVersion.HTTP_1_0, 298);
         Assert.assertEquals(HttpVersion.HTTP_1_0, response.getStatusLine().getProtocolVersion());
         Assert.assertEquals(298, response.getStatusLine().getStatusCode());



Mime
View raw message