about summary refs log tree commit homepage
path: root/http_common.rl
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2012-01-26 19:27:56 -0800
committerEric Wong <normalperson@yhbt.net>2012-01-27 09:44:06 +0000
commite90a01d7bfefbeca59ec9fdf8113c4d5de1fb69e (patch)
tree46f979e781493d59798c984c62c2410da9fbe2d3 /http_common.rl
parent506f3dc4701256c62fa37c0ab6be2748da60f098 (diff)
downloadcmogstored-e90a01d7bfefbeca59ec9fdf8113c4d5de1fb69e.tar.gz
This should make life easier for us when integrating chunk
reading functionality
Diffstat (limited to 'http_common.rl')
-rw-r--r--http_common.rl28
1 files changed, 25 insertions, 3 deletions
diff --git a/http_common.rl b/http_common.rl
index cb5bc8b..703017c 100644
--- a/http_common.rl
+++ b/http_common.rl
@@ -9,9 +9,9 @@
         LF = '\n' > { http->line_end = to_u16(fpc - buf); };
         eor = LWS*'\r'LF;
         CTL = (cntrl | 127);
-        header_name = [a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9];
-        header_value = (any -- CTL)*;
-        sep = LWS+|LWS*"\r\n"LWS+;
+        header_name = [a-zA-Z0-9\-]+;
+        header_value = (any -- (LWS|CTL))(any -- CTL)*;
+        sep = (LWS*)|(eor LWS+);
         b64_val = ([a-zA-Z0-9/+]{22}) > { http->tmp_tip = to_u16(fpc - buf); }
                   "=="
                   eor > {
@@ -28,4 +28,26 @@
                         http->has_expect_md5 = 1;
                   };
         content_md5 = "Content-MD5:"i sep b64_val;
+
+        ignored_trailer := header_name ':' sep header_value eor @ {
+                fgoto more_trailers;
+        };
+        trailer_line = ( content_md5 ) $!
+                {
+                        if (http->line_end > 0) {
+                                assert(buf[http->line_end] == '\n'
+                                       && "bad http->line_end");
+                                p = buf + http->line_end + 1;
+                        } else {
+                                p = buf;
+                        }
+                        assert(p <= pe && "overflow");
+                        fgoto ignored_trailer;
+                };
+        trailers = trailer_line* '\r''\n' > {
+                http->chunk_state = MOG_CHUNK_STATE_DONE;
+                really_done = 1;
+                fbreak;
+        };
+        more_trailers := trailers;
 }%%