cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1310260 - in /cxf/branches/2.3.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestImpl.java rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestImplTest.java
Date Fri, 06 Apr 2012 09:28:22 GMT
Author: sergeyb
Date: Fri Apr  6 09:28:22 2012
New Revision: 1310260

URL: http://svn.apache.org/viewvc?rev=1310260&view=rev
Log:
Merged revisions 1310259 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.4.x-fixes

................
  r1310259 | sergeyb | 2012-04-06 12:24:38 +0300 (Fri, 06 Apr 2012) | 16 lines
  
  Merged revisions 1310258 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/branches/2.5.x-fixes
  
  ................
    r1310258 | sergeyb | 2012-04-06 12:20:36 +0300 (Fri, 06 Apr 2012) | 9 lines
    
    Merged revisions 1310252 via svnmerge from 
    https://svn.apache.org/repos/asf/cxf/trunk
    
    ........
      r1310252 | sergeyb | 2012-04-06 12:16:38 +0300 (Fri, 06 Apr 2012) | 1 line
      
      [CXF-4231] Handling If-None-Match and If-Modified-Since pair as recommended by HTTP
spec, patch from Jan Engehausen applied with thanks
    ........
  ................
................

Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestImpl.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestImplTest.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/branches/2.5.x-fixes:r1310258
  Merged /cxf/branches/2.4.x-fixes:r1310259
  Merged /cxf/trunk:r1310252

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestImpl.java?rev=1310260&r1=1310259&r2=1310260&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestImpl.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestImpl.java
Fri Apr  6 09:28:22 2012
@@ -205,12 +205,16 @@ public class RequestImpl implements Requ
 
 
     public ResponseBuilder evaluatePreconditions(Date lastModified, EntityTag eTag) {
-        ResponseBuilder rb = evaluatePreconditions(eTag);
+        final ResponseBuilder rb = evaluatePreconditions(eTag);
         if (rb != null) {
-            return rb;
+            // the ETag conditions match; so now conditions for last modified must match
+            return evaluatePreconditions(lastModified);
+        } else {
+            // the ETag conditions do not match, so last modified should be ignored
+            // see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html (section 14.26
for
+            // "If-None-Match", behavior not specified for "If-Match", section 14.24)
+            return null;
         }
-        return evaluatePreconditions(lastModified);
-                
     }
     
     public String getMethod() {

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestImplTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestImplTest.java?rev=1310260&r1=1310259&r2=1310260&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestImplTest.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestImplTest.java
Fri Apr  6 09:28:22 2012
@@ -268,5 +268,34 @@ public class RequestImplTest extends Ass
         Response r = rb.build();
         assertEquals("If-Modified-Since precondition was not met", 304, r.getStatus());
     }
+    
+    @Test
+    public void testIfNoneMatchAndDateWithMatchingTags() throws Exception {
+        metadata.putSingle(HttpHeaders.IF_NONE_MATCH, "\"123\"");
+        metadata.putSingle("If-Modified-Since", "Tue, 21 Oct 2008 14:00:00 GMT");
+        
+        Date lastModified = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH)
+            .parse("Mon, 20 Oct 2008 14:00:00 GMT");
+        
+        ResponseBuilder rb = 
+            new RequestImpl(m).evaluatePreconditions(lastModified, new EntityTag("123"));
+        assertNotNull("Precondition is not met", rb);
+        
+        Response r = rb.build();
+        assertEquals("If-Modified-Since precondition was not met", 304, r.getStatus());
+    }
+    
+    @Test
+    public void testIfNoneMatchAndDateWithNonMatchingTags() throws Exception {
+        metadata.putSingle(HttpHeaders.IF_NONE_MATCH, "\"123\"");
+        metadata.putSingle("If-Modified-Since", "Tue, 21 Oct 2008 14:00:00 GMT");
+        
+        Date lastModified = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH)
+            .parse("Mon, 20 Oct 2008 14:00:00 GMT");
+        
+        ResponseBuilder rb = 
+            new RequestImpl(m).evaluatePreconditions(lastModified, new EntityTag("124"));
+        assertNull("Dates must not be checked if tags do not match", rb);
+    }
    
 }



Mime
View raw message