2 * Copyright (C) 2012-2020 all contributors <cmogstored-public@yhbt.net>
3 * License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
9 LF = '\n' > { http->_p.line_end = to_u16(fpc - buf); };
12 header_name = [a-zA-Z0-9\-]+;
13 header_value = (any -- CTL)*;
14 sep = (LWS*)|(eor LWS+);
15 b64_val = ([a-zA-Z0-9/+]{22}) > {
16 http->_p.tmp_tip = to_u16(fpc - buf);
20 uint16_t tmp_end = to_u16(fpc - buf);
21 char *in = buf + http->_p.tmp_tip;
22 size_t inlen = tmp_end - http->_p.tmp_tip;
23 char *out = (char *)http->expect_md5;
24 size_t outlen = sizeof(http->expect_md5);
28 * Ragel already validated the allowable bytes,
29 * so base64_decode_ctx must succeed:
31 rc = base64_decode_ctx(NULL, in, inlen, out, &outlen);
32 assert(rc == true && outlen == 16
33 && "base64_decoder broke for HTTP");
36 content_md5 = "Content-MD5:"i sep ( b64_val ) $! {
37 if (!http->_p.has_md5) {
42 ignored_trailer := header_name ':' sep header_value eor @ {
45 trailer_line = ( content_md5 ) $!
47 if (http->_p.line_end > 0) {
48 assert(buf[http->_p.line_end] == '\n'
49 && "bad http->_p.line_end");
50 p = buf + http->_p.line_end + 1;
54 assert(p <= pe && "overflow");
55 fgoto ignored_trailer;
57 trailers = trailer_line* '\r''\n' > {
58 http->_p.chunk_state = MOG_CHUNK_STATE_DONE;
59 http->_p.line_end = to_u16(fpc - buf);
63 more_trailers := trailers;