Author: rhuijben
Date: Sat Nov 14 14:34:38 2015
New Revision: 1714338

URL: http://svn.apache.org/viewvc?rev=1714338&view=rev
Log:
Reinstate the optimization for explicit CRLF, removed in r1713955
with a comment explaining this very specific case.

* buckets/buckets.c
  (serf_bucket_limited_readline): Reinstate CRLF optimization. Fix
    the ugly corner case where somebody tries to read a line of
    0 or 1 bytes.

Modified:
    serf/trunk/buckets/buckets.c

Modified: serf/trunk/buckets/buckets.c
URL: 
http://svn.apache.org/viewvc/serf/trunk/buckets/buckets.c?rev=1714338&r1=1714337&r2=1714338&view=diff
==============================================================================
--- serf/trunk/buckets/buckets.c (original)
+++ serf/trunk/buckets/buckets.c Sat Nov 14 14:34:38 2015
@@ -151,8 +151,18 @@ apr_status_t serf_bucket_limited_readlin
 
            For example, if we tried reading 2 characters seeking CRLF, and
            got CR followed by 'a', then we have over-read the line, and
-           consumed a character from the next line. Bad.  */
-        requested = 1;
+           consumed a character from the next line. Bad.
+
+           The only exception is when we *only* allow CRLF as newline. In that
+           case CR followed by 'a' would just be raw line data, not a line
+           break followed by data. If we allow any other type of newline we
+           can't use this trick.
+         */
+
+        if ((acceptable & SERF_NEWLINE_ANY) == SERF_NEWLINE_CRLF)
+            requested = MIN(requested, 2); /* Only CRLF is allowed */
+        else
+            requested = MIN(requested, 1);
     }
     else {
         /* peek_len > 0  */


Reply via email to