diff options
Diffstat (limited to 'http_common.rl')
-rw-r--r-- | http_common.rl | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/http_common.rl b/http_common.rl index 8df5fed..de54bc1 100644 --- a/http_common.rl +++ b/http_common.rl @@ -6,18 +6,20 @@ machine http_common; LWS = (' ' | '\t'); - LF = '\n' > { http->line_end = to_u16(fpc - buf); }; + LF = '\n' > { http->_p.line_end = to_u16(fpc - buf); }; eor = LWS*'\r'LF; CTL = (cntrl | 127); 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 > { + b64_val = ([a-zA-Z0-9/+]{22}) > { + http->_p.tmp_tip = to_u16(fpc - buf); + } + "==" + eor > { uint16_t tmp_end = to_u16(fpc - buf); - char *in = buf + http->tmp_tip; - size_t inlen = tmp_end - http->tmp_tip; + char *in = buf + http->_p.tmp_tip; + size_t inlen = tmp_end - http->_p.tmp_tip; char *out = (char *)http->expect_md5; size_t outlen = sizeof(http->expect_md5); bool rc; @@ -25,10 +27,10 @@ rc = base64_decode_ctx(NULL, in, inlen, out, &outlen); assert(rc == true && outlen == 16 && "base64_decoder broke for HTTP"); - http->has_expect_md5 = 1; - }; + http->_p.has_expect_md5 = 1; + }; content_md5 = "Content-MD5:"i sep ( b64_val ) $! { - if (!http->has_expect_md5) { + if (!http->_p.has_expect_md5) { errno = EINVAL; fbreak; } @@ -38,10 +40,10 @@ }; 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; + if (http->_p.line_end > 0) { + assert(buf[http->_p.line_end] == '\n' + && "bad http->_p.line_end"); + p = buf + http->_p.line_end + 1; } else { p = buf; } @@ -49,8 +51,8 @@ fgoto ignored_trailer; }; trailers = trailer_line* '\r''\n' > { - http->chunk_state = MOG_CHUNK_STATE_DONE; - http->line_end = to_u16(fpc - buf); + http->_p.chunk_state = MOG_CHUNK_STATE_DONE; + http->_p.line_end = to_u16(fpc - buf); really_done = 1; fbreak; }; |