Revision: 14644
Author: adrian.chadd
Date: Sun May  9 22:51:01 2010
Log: Issue #108 - finish modifying hh_check_content_length() to take const char * + len rather than String.

This API modification has been done so the header contents can be checked before
they are "parsed" into String entries.

This is a step backwards but is only meant to be temporary. At least,
until String refencing becomes cheap. It'll then be undone.


http://code.google.com/p/lusca-cache/source/detail?r=14644

Modified:
 /branches/LUSCA_HEAD/libhttp/HttpHeaderParse.c
 /branches/LUSCA_HEAD/test-suite/libhttp/test_libhttp_1.c

=======================================
--- /branches/LUSCA_HEAD/libhttp/HttpHeaderParse.c      Sun May  9 10:00:16 2010
+++ /branches/LUSCA_HEAD/libhttp/HttpHeaderParse.c      Sun May  9 22:51:01 2010
@@ -90,13 +90,13 @@
  * be removed!
  */
 int
-hh_check_content_length(HttpHeader *hdr, String *value)
+hh_check_content_length(HttpHeader *hdr, const char *var, int vlen)
 {
            squid_off_t l1, l2;
            HttpHeaderEntry *e2;

-           if (!httpHeaderParseSize2(strBuf2(*value), strLen2(*value), &l1)) {
- debug(55, 1) ("WARNING: Unparseable content-length '%.*s'\n", strLen2(*value), strBuf2(*value));
+           if (!httpHeaderParseSize2(var, vlen, &l1)) {
+               debug(55, 1) ("WARNING: Unparseable content-length '%.*s'\n", 
vlen, var);
                return -1;
            }
            e2 = httpHeaderFindEntry(hdr, HDR_CONTENT_LENGTH);
@@ -106,8 +106,8 @@
                 return 1;

            /* Do the contents match? */
-           if ((strLen2(*value) == strLen2(e2->value)) &&
-               (strNCmp(e2->value, strBuf2(*value), strLen2(*value)) == 0)) {
+           if ((vlen == strLen2(e2->value)) &&
+               (strNCmp(e2->value, var, vlen) == 0)) {
debug(55, httpConfig_relaxed_parser <= 0 ? 1 : 2) ("NOTICE: found double content-length header\n");
                if (httpConfig_relaxed_parser) {
                    return 0;
@@ -127,7 +127,7 @@

/* Is the original entry parseable? If not, definitely error out. It shouldn't be here */ if (!httpHeaderParseSize2(strBuf2(e2->value), strLen2(e2->value), &l2)) { - debug(55, 1) ("WARNING: Unparseable content-length '%.*s'\n", strLen2(*value), strBuf2(*value)); + debug(55, 1) ("WARNING: Unparseable content-length '%.*s'\n", vlen, var);
                return -1;
            }

@@ -150,7 +150,7 @@
httpHeaderParseCheckEntry(HttpHeader *hdr, int id, String *name, String *value)
 {
        if (id == HDR_CONTENT_LENGTH) {
-               return(hh_check_content_length(hdr, value));
+               return(hh_check_content_length(hdr, strBuf2(*value), 
strLen2(*value)));
        }
        return 1;
 }
=======================================
--- /branches/LUSCA_HEAD/test-suite/libhttp/test_libhttp_1.c Sun May 9 02:10:53 2010 +++ /branches/LUSCA_HEAD/test-suite/libhttp/test_libhttp_1.c Sun May 9 22:51:01 2010
@@ -43,19 +43,15 @@
 #include "libhttp/HttpHeaderMask.h"
 #include "libhttp/HttpHeaderParse.h"

-extern int hh_check_content_length(HttpHeader *hdr, String *value);
+extern int hh_check_content_length(HttpHeader *hdr, const char *val, int vlen);

 static int
 test_hh_content_length(HttpHeader *hdr, const char *str)
 {
-       String val = StringNull;
        int r;

-       stringInit(&val, str);
-
        /* XXX remember; this may delete items from the header entry array! */
-       r = hh_check_content_length(hdr, &val);
-       stringClean(&val);
+       r = hh_check_content_length(hdr, str, strlen(str));
        return r;
 }

--
You received this message because you are subscribed to the Google Groups 
"lusca-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/lusca-commit?hl=en.

Reply via email to