mongrel_esi 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +10 -9
- data/doc/rdoc/classes/ESI/Cache.html +10 -10
- data/doc/rdoc/classes/ESI/Cache.src/{M000085.html → M000087.html} +0 -0
- data/doc/rdoc/classes/ESI/Cache.src/{M000086.html → M000088.html} +0 -0
- data/doc/rdoc/classes/ESI/Config.html +43 -62
- data/doc/rdoc/classes/ESI/Config.src/M000049.html +18 -0
- data/doc/rdoc/classes/ESI/Config.src/{M000059.html → M000050.html} +5 -5
- data/doc/rdoc/classes/ESI/Config.src/M000051.html +35 -0
- data/doc/rdoc/classes/ESI/Config.src/M000052.html +27 -5
- data/doc/rdoc/classes/ESI/Config.src/M000053.html +10 -5
- data/doc/rdoc/classes/ESI/Config.src/M000054.html +5 -22
- data/doc/rdoc/classes/ESI/Config.src/M000055.html +7 -25
- data/doc/rdoc/classes/ESI/Config.src/M000056.html +11 -10
- data/doc/rdoc/classes/ESI/Config/CacheConfig.html +25 -25
- data/doc/rdoc/classes/ESI/Config/CacheConfig.src/{M000068.html → M000060.html} +6 -5
- data/doc/rdoc/classes/ESI/Config/CacheConfig.src/{M000065.html → M000061.html} +5 -5
- data/doc/rdoc/classes/ESI/Config/CacheConfig.src/{M000066.html → M000062.html} +4 -4
- data/doc/rdoc/classes/ESI/Config/CacheConfig.src/{M000067.html → M000063.html} +4 -4
- data/doc/rdoc/classes/ESI/Config/CacheConfig.src/M000064.html +5 -6
- data/doc/rdoc/classes/ESI/Config/ConfigRouter.html +15 -15
- data/doc/rdoc/classes/ESI/Config/ConfigRouter.src/{M000061.html → M000057.html} +5 -5
- data/doc/rdoc/classes/ESI/Config/ConfigRouter.src/{M000062.html → M000058.html} +7 -7
- data/doc/rdoc/classes/ESI/Config/ConfigRouter.src/{M000063.html → M000059.html} +7 -7
- data/doc/rdoc/classes/ESI/Dispatcher.html +17 -15
- data/doc/rdoc/classes/ESI/Dispatcher.src/{M000087.html → M000092.html} +4 -7
- data/doc/rdoc/classes/ESI/Dispatcher.src/M000093.html +27 -0
- data/doc/rdoc/classes/ESI/Fragment.html +15 -15
- data/doc/rdoc/classes/ESI/Fragment.src/{M000100.html → M000111.html} +0 -0
- data/doc/rdoc/classes/ESI/Fragment.src/{M000101.html → M000112.html} +0 -0
- data/doc/rdoc/classes/ESI/Fragment.src/{M000102.html → M000113.html} +0 -0
- data/doc/rdoc/classes/ESI/MemcachedCache.html +46 -46
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000037.html +24 -0
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000038.html +22 -0
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000039.html +19 -0
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000040.html +10 -11
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000041.html +5 -9
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000042.html +6 -6
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000043.html +5 -10
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000044.html +5 -5
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000045.html +4 -6
- data/doc/rdoc/classes/ESI/OutputAdapter.html +204 -0
- data/doc/rdoc/classes/ESI/OutputAdapter.src/M000094.html +37 -0
- data/doc/rdoc/classes/ESI/OutputAdapter.src/M000095.html +18 -0
- data/doc/rdoc/classes/ESI/OutputAdapter.src/M000096.html +18 -0
- data/doc/rdoc/classes/ESI/OutputAdapter.src/M000097.html +18 -0
- data/doc/rdoc/classes/ESI/Parser.html +15 -15
- data/doc/rdoc/classes/ESI/Parser.src/{M000049.html → M000065.html} +0 -0
- data/doc/rdoc/classes/ESI/Parser.src/{M000050.html → M000066.html} +0 -0
- data/doc/rdoc/classes/ESI/Parser.src/{M000051.html → M000067.html} +0 -0
- data/doc/rdoc/classes/ESI/Processor.html +15 -15
- data/doc/rdoc/classes/ESI/Processor.src/{M000037.html → M000046.html} +0 -0
- data/doc/rdoc/classes/ESI/Processor.src/{M000038.html → M000047.html} +1 -1
- data/doc/rdoc/classes/ESI/Processor.src/{M000039.html → M000048.html} +0 -0
- data/doc/rdoc/classes/ESI/Proxy.html +48 -48
- data/doc/rdoc/classes/ESI/Proxy.src/M000071.html +7 -40
- data/doc/rdoc/classes/ESI/Proxy.src/M000072.html +50 -12
- data/doc/rdoc/classes/ESI/Proxy.src/M000073.html +49 -6
- data/doc/rdoc/classes/ESI/Proxy.src/M000074.html +11 -14
- data/doc/rdoc/classes/ESI/Proxy.src/M000075.html +6 -5
- data/doc/rdoc/classes/ESI/Proxy.src/M000076.html +9 -15
- data/doc/rdoc/classes/ESI/Proxy.src/M000077.html +5 -16
- data/doc/rdoc/classes/ESI/Proxy.src/M000078.html +28 -0
- data/doc/rdoc/classes/ESI/Proxy.src/M000079.html +29 -0
- data/doc/rdoc/classes/ESI/RackAdapter.html +214 -0
- data/doc/rdoc/classes/ESI/RackAdapter.src/M000068.html +18 -0
- data/doc/rdoc/classes/ESI/RackAdapter.src/M000069.html +34 -0
- data/doc/rdoc/classes/ESI/{MemcachedCache.src/M000048.html → RackAdapter.src/M000070.html} +4 -4
- data/doc/rdoc/classes/ESI/RackConfig.html +173 -0
- data/doc/rdoc/classes/ESI/RackConfig.src/M000089.html +28 -0
- data/doc/rdoc/classes/ESI/RackConfig.src/M000090.html +18 -0
- data/doc/rdoc/classes/ESI/RackConfig.src/M000091.html +20 -0
- data/doc/rdoc/classes/ESI/Request.html +158 -0
- data/doc/rdoc/classes/ESI/{MemcachedCache.src/M000046.html → Request.src/M000098.html} +5 -5
- data/doc/rdoc/classes/ESI/Request.src/M000099.html +18 -0
- data/doc/rdoc/classes/ESI/Response.html +36 -36
- data/doc/rdoc/classes/ESI/Response.src/M000080.html +10 -8
- data/doc/rdoc/classes/ESI/Response.src/M000081.html +5 -7
- data/doc/rdoc/classes/ESI/Response.src/M000082.html +8 -12
- data/doc/rdoc/classes/ESI/Response.src/M000083.html +7 -5
- data/doc/rdoc/classes/ESI/Response.src/M000084.html +12 -20
- data/doc/rdoc/classes/ESI/Response.src/{M000079.html → M000085.html} +5 -5
- data/doc/rdoc/classes/ESI/Response.src/M000086.html +33 -0
- data/doc/rdoc/classes/ESI/Router.html +10 -10
- data/doc/rdoc/classes/ESI/Router.src/{M000098.html → M000109.html} +0 -0
- data/doc/rdoc/classes/ESI/Router.src/{M000099.html → M000110.html} +0 -0
- data/doc/rdoc/classes/ESI/RubyCache.html +45 -45
- data/doc/rdoc/classes/ESI/RubyCache.src/{M000089.html → M000100.html} +6 -6
- data/doc/rdoc/classes/ESI/RubyCache.src/{M000090.html → M000101.html} +6 -6
- data/doc/rdoc/classes/ESI/RubyCache.src/{M000091.html → M000102.html} +6 -6
- data/doc/rdoc/classes/ESI/RubyCache.src/{M000092.html → M000103.html} +8 -8
- data/doc/rdoc/classes/ESI/RubyCache.src/{M000093.html → M000104.html} +4 -4
- data/doc/rdoc/classes/ESI/RubyCache.src/{M000094.html → M000105.html} +8 -8
- data/doc/rdoc/classes/ESI/RubyCache.src/{M000095.html → M000106.html} +4 -4
- data/doc/rdoc/classes/ESI/RubyCache.src/{M000096.html → M000107.html} +4 -4
- data/doc/rdoc/classes/ESI/RubyCache.src/{M000097.html → M000108.html} +4 -4
- data/doc/rdoc/classes/ESI/Tag.html +8 -8
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/COPYING.html +1 -1
- data/doc/rdoc/files/LICENSE.html +1 -1
- data/doc/rdoc/files/README.html +12 -10
- data/doc/rdoc/files/ext/esi/common_rl.html +1 -1
- data/doc/rdoc/files/ext/esi/esi_parser_c.html +1 -1
- data/doc/rdoc/files/ext/esi/parser_c.html +1 -1
- data/doc/rdoc/files/ext/esi/parser_h.html +1 -1
- data/doc/rdoc/files/ext/esi/parser_rl.html +122 -82
- data/doc/rdoc/files/ext/esi/test/test_c.html +1 -1
- data/doc/rdoc/files/lib/esi/cache_rb.html +2 -1
- data/doc/rdoc/files/lib/esi/config_rb.html +2 -1
- data/doc/rdoc/files/lib/esi/dispatcher_rb.html +3 -1
- data/doc/rdoc/files/lib/esi/invalidator_rb.html +1 -1
- data/doc/rdoc/files/lib/esi/logger_rb.html +1 -1
- data/doc/rdoc/files/lib/esi/parser_rb.html +1 -1
- data/doc/rdoc/files/lib/esi/processor_rb.html +1 -1
- data/doc/rdoc/files/lib/esi/proxy_rb.html +2 -2
- data/doc/rdoc/files/{ext/esi/test/parser_c.html → lib/esi/rack_adapter_rb.html} +21 -5
- data/doc/rdoc/files/lib/esi/response_rb.html +1 -1
- data/doc/rdoc/files/lib/esi/router_rb.html +1 -1
- data/doc/rdoc/files/lib/esi/tag/attempt_rb.html +1 -1
- data/doc/rdoc/files/lib/esi/tag/base_rb.html +1 -1
- data/doc/rdoc/files/lib/esi/tag/container_rb.html +1 -1
- data/doc/rdoc/files/lib/esi/tag/except_rb.html +1 -1
- data/doc/rdoc/files/lib/esi/tag/include_rb.html +1 -1
- data/doc/rdoc/files/lib/esi/tag/invalidate_rb.html +1 -1
- data/doc/rdoc/files/lib/esi/tag/try_rb.html +1 -1
- data/doc/rdoc/files/lib/esi/version_rb.html +1 -1
- data/doc/rdoc/files/lib/multi_dirhandler_rb.html +1 -1
- data/doc/rdoc/fr_class_index.html +4 -0
- data/doc/rdoc/fr_file_index.html +1 -5
- data/doc/rdoc/fr_method_index.html +87 -76
- data/ext/esi/esi_parser.c +2 -2
- data/ext/esi/parser.c +133 -107
- data/ext/esi/parser.h +9 -4
- data/ext/esi/parser.rl +99 -73
- data/ext/esi/test/test.c +11 -6
- data/lib/esi/cache.rb +7 -3
- data/lib/esi/config.rb +4 -8
- data/lib/esi/dispatcher.rb +14 -5
- data/lib/esi/processor.rb +1 -1
- data/lib/esi/proxy.rb +58 -48
- data/lib/esi/rack_adapter.rb +97 -0
- data/lib/esi/response.rb +30 -1
- data/lib/esi/version.rb +1 -1
- data/test/bench-plot.rb +31 -0
- data/test/benchmarks/csv-perf-serial0.4 +101 -0
- data/test/benchmarks/csv-perf-trunk +101 -0
- data/test/benchmarks/perf-serial0.4-n1000-c1.csv +101 -0
- data/test/benchmarks/perf-serial0.4-n1000-c2.csv +101 -0
- data/test/benchmarks/perf-serial0.4-n1000-c3.csv +101 -0
- data/test/benchmarks/perf-serial0.4-n1000-c4.csv +101 -0
- data/test/benchmarks/perf-serial0.4-n1000-c5.csv +101 -0
- data/test/benchmarks/perf-serial0.4-n1000-c6.csv +101 -0
- data/test/benchmarks/perf-serial0.4-n1000-c7.csv +101 -0
- data/test/benchmarks/perf-trunk-n1000-c1.csv +101 -0
- data/test/benchmarks/perf-trunk-n1000-c2.csv +101 -0
- data/test/benchmarks/perf-trunk-n1000-c3.csv +101 -0
- data/test/benchmarks/perf-trunk-n1000-c4.csv +101 -0
- data/test/benchmarks/perf-trunk-n1000-c5.csv +101 -0
- data/test/benchmarks/perf-trunk-n1000-c6.csv +101 -0
- data/test/benchmarks/perf-trunk-n1000-c7.csv +101 -0
- data/test/load_test.rb +5 -2
- data/test/load_test_ab.rb +9 -4
- metadata +261 -227
- data/doc/rdoc/classes/ESI/Config.src/M000057.html +0 -18
- data/doc/rdoc/classes/ESI/Config.src/M000058.html +0 -20
- data/doc/rdoc/classes/ESI/Config.src/M000060.html +0 -24
- data/doc/rdoc/classes/ESI/Dispatcher.src/M000088.html +0 -18
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000047.html +0 -18
- data/doc/rdoc/classes/ESI/Proxy.src/M000069.html +0 -20
- data/doc/rdoc/classes/ESI/Proxy.src/M000070.html +0 -55
- data/doc/rdoc/classes/ESI/Response.src/M000078.html +0 -23
- data/doc/rdoc/files/ext/esi/test/common_rl.html +0 -160
- data/doc/rdoc/files/ext/esi/test/parser_h.html +0 -101
- data/doc/rdoc/files/ext/esi/test/parser_rl.html +0 -827
- data/doc/rdoc/files/ext/esi/test/sp_c.html +0 -101
- data/ext/esi/test/common.rl +0 -46
- data/ext/esi/test/parser.c +0 -1875
- data/ext/esi/test/parser.h +0 -120
- data/ext/esi/test/parser.rl +0 -585
- data/ext/esi/test/sp.c +0 -125
data/ext/esi/esi_parser.c
CHANGED
|
@@ -92,8 +92,8 @@ esi_parser_default_start_cb( const void *data,
|
|
|
92
92
|
VALUE attr_hash = rb_hash_new();
|
|
93
93
|
VALUE tag_text = rb_str_new( name_start, name_length );
|
|
94
94
|
while( attr ){
|
|
95
|
-
VALUE name = rb_str_new( attr->name,
|
|
96
|
-
VALUE value = rb_str_new( attr->value,
|
|
95
|
+
VALUE name = rb_str_new( attr->name, attr->name_length );
|
|
96
|
+
VALUE value = rb_str_new( attr->value, attr->value_length );
|
|
97
97
|
rb_hash_aset( attr_hash, name, value );
|
|
98
98
|
attr = attr->next;
|
|
99
99
|
}
|
data/ext/esi/parser.c
CHANGED
|
@@ -65,6 +65,21 @@ static void esi_parser_echo_char( ESIParser *parser, char ch )
|
|
|
65
65
|
esi_parser_flush_output( parser );
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
+
static void esi_parser_send_buffer( ESIParser *parser, const char *seq, size_t len )
|
|
69
|
+
{
|
|
70
|
+
const char *nseq = seq + len;
|
|
71
|
+
size_t nlen = parser->output_buffer_size + len;
|
|
72
|
+
|
|
73
|
+
if( nlen < ESI_OUTPUT_BUFFER_SIZE ) {
|
|
74
|
+
memcpy( parser->output_buffer + parser->output_buffer_size, seq, len );
|
|
75
|
+
parser->output_buffer_size += len;
|
|
76
|
+
}
|
|
77
|
+
else if( nlen > ESI_OUTPUT_BUFFER_SIZE ) {
|
|
78
|
+
while( seq != nseq ) {
|
|
79
|
+
esi_parser_echo_char( parser, *seq++ );
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
68
83
|
/* send any buffered characters to the output handler.
|
|
69
84
|
* This happens when we enter a case such as <em> where the
|
|
70
85
|
* first two characters < and e match the <esi: expression
|
|
@@ -100,6 +115,7 @@ static void esi_parser_concat_to_echobuffer( ESIParser *parser, char ch )
|
|
|
100
115
|
/* double the echobuffer size
|
|
101
116
|
* we're getting some crazy input if this case ever happens
|
|
102
117
|
*/
|
|
118
|
+
printf( "increase echobuffer: %d, %s\n", parser->echobuffer_allocated, parser->echobuffer );
|
|
103
119
|
parser->echobuffer_allocated *= 2;
|
|
104
120
|
parser->echobuffer = (char*)realloc( parser->echobuffer, parser->echobuffer_allocated );
|
|
105
121
|
}
|
|
@@ -139,11 +155,11 @@ static void rtrim_pointer( const char **ptr, const char *bounds, size_t *len )
|
|
|
139
155
|
}
|
|
140
156
|
}
|
|
141
157
|
|
|
142
|
-
#line
|
|
158
|
+
#line 321 "parser.rl"
|
|
143
159
|
|
|
144
160
|
|
|
145
161
|
|
|
146
|
-
#line
|
|
162
|
+
#line 163 "parser.c"
|
|
147
163
|
static const char _esi_eof_actions[] = {
|
|
148
164
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
149
165
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
@@ -163,7 +179,7 @@ static const int esi_error = -1;
|
|
|
163
179
|
|
|
164
180
|
static const int esi_en_main = 75;
|
|
165
181
|
|
|
166
|
-
#line
|
|
182
|
+
#line 324 "parser.rl"
|
|
167
183
|
|
|
168
184
|
/* dup the string up to len */
|
|
169
185
|
char *esi_strndup( const char *str, size_t len )
|
|
@@ -177,8 +193,10 @@ char *esi_strndup( const char *str, size_t len )
|
|
|
177
193
|
ESIAttribute *esi_attribute_new( const char *name, size_t name_length, const char *value, size_t value_length )
|
|
178
194
|
{
|
|
179
195
|
ESIAttribute *attr = (ESIAttribute*)malloc(sizeof(ESIAttribute));
|
|
180
|
-
attr->name = esi_strndup(name, name_length);
|
|
181
|
-
attr->value = esi_strndup(value, value_length);
|
|
196
|
+
attr->name = name;//esi_strndup(name, name_length);
|
|
197
|
+
attr->value = value;//esi_strndup(value, value_length);
|
|
198
|
+
attr->name_length = name_length;
|
|
199
|
+
attr->value_length = value_length;
|
|
182
200
|
attr->next = NULL;
|
|
183
201
|
return attr;
|
|
184
202
|
}
|
|
@@ -189,16 +207,16 @@ ESIAttribute *esi_attribute_copy( ESIAttribute *attribute )
|
|
|
189
207
|
if( !attribute ){ return NULL; }
|
|
190
208
|
|
|
191
209
|
// copy the first attribute
|
|
192
|
-
nattr = esi_attribute_new( attribute->name,
|
|
193
|
-
attribute->value,
|
|
210
|
+
nattr = esi_attribute_new( attribute->name, attribute->name_length,
|
|
211
|
+
attribute->value, attribute->value_length );
|
|
194
212
|
// save a pointer for return
|
|
195
213
|
head = nattr;
|
|
196
214
|
// copy next attributes
|
|
197
215
|
attribute = attribute->next;
|
|
198
216
|
while( attribute ) {
|
|
199
217
|
// set the next attribute
|
|
200
|
-
nattr->next = esi_attribute_new( attribute->name,
|
|
201
|
-
attribute->value,
|
|
218
|
+
nattr->next = esi_attribute_new( attribute->name, attribute->name_length,
|
|
219
|
+
attribute->value, attribute->value_length );
|
|
202
220
|
// next attribute
|
|
203
221
|
nattr = nattr->next;
|
|
204
222
|
attribute = attribute->next;
|
|
@@ -210,8 +228,8 @@ void esi_attribute_free( ESIAttribute *attribute )
|
|
|
210
228
|
{
|
|
211
229
|
ESIAttribute *ptr;
|
|
212
230
|
while( attribute ){
|
|
213
|
-
free( attribute->name );
|
|
214
|
-
free( attribute->value );
|
|
231
|
+
// free( attribute->name );
|
|
232
|
+
// free( attribute->value );
|
|
215
233
|
ptr = attribute->next;
|
|
216
234
|
free( attribute );
|
|
217
235
|
attribute = ptr;
|
|
@@ -228,9 +246,11 @@ ESIParser *esi_parser_new()
|
|
|
228
246
|
parser->attr_value = NULL;
|
|
229
247
|
parser->overflow_data_size = 0;
|
|
230
248
|
parser->overflow_data = NULL;
|
|
249
|
+
parser->overflow_data_allocated = 0;
|
|
250
|
+
parser->using_overflow = 0;
|
|
231
251
|
|
|
232
252
|
/* allocate ESI_OUTPUT_BUFFER_SIZE bytes for the echobuffer */
|
|
233
|
-
parser->echobuffer_allocated =
|
|
253
|
+
parser->echobuffer_allocated = ESI_ECHOBUFFER_SIZE;
|
|
234
254
|
parser->echobuffer_index = -1;
|
|
235
255
|
parser->echobuffer = (char*)malloc(sizeof(char)*parser->echobuffer_allocated);
|
|
236
256
|
|
|
@@ -251,6 +271,7 @@ void esi_parser_free( ESIParser *parser )
|
|
|
251
271
|
if( parser->overflow_data ){ free( parser->overflow_data ); }
|
|
252
272
|
|
|
253
273
|
free( parser->echobuffer );
|
|
274
|
+
|
|
254
275
|
esi_attribute_free( parser->attributes );
|
|
255
276
|
|
|
256
277
|
free( parser );
|
|
@@ -265,11 +286,11 @@ int esi_parser_init( ESIParser *parser )
|
|
|
265
286
|
{
|
|
266
287
|
int cs;
|
|
267
288
|
|
|
268
|
-
#line
|
|
289
|
+
#line 290 "parser.c"
|
|
269
290
|
{
|
|
270
291
|
cs = esi_start;
|
|
271
292
|
}
|
|
272
|
-
#line
|
|
293
|
+
#line 430 "parser.rl"
|
|
273
294
|
parser->prev_state = parser->cs = cs;
|
|
274
295
|
return 0;
|
|
275
296
|
}
|
|
@@ -328,6 +349,54 @@ esi_parser_scan_for_start( ESIParser *parser, const char *data, size_t length )
|
|
|
328
349
|
}
|
|
329
350
|
}
|
|
330
351
|
|
|
352
|
+
static void
|
|
353
|
+
esi_parser_append_data_to_overflow_data( ESIParser *parser, const char *data, size_t length )
|
|
354
|
+
{
|
|
355
|
+
int mark_offset = 0;
|
|
356
|
+
int tag_text_offset = 0;
|
|
357
|
+
int attr_key_offset = 0;
|
|
358
|
+
int attr_value_offset = 0;
|
|
359
|
+
|
|
360
|
+
if( parser->using_overflow ) {
|
|
361
|
+
// recompute mark, tag_text, attr_key, and attr_value as they all exist within overflow_data
|
|
362
|
+
mark_offset = compute_offset( parser->mark, parser->overflow_data );
|
|
363
|
+
tag_text_offset = compute_offset( parser->tag_text, parser->overflow_data );
|
|
364
|
+
attr_key_offset = compute_offset( parser->attr_key, parser->overflow_data );
|
|
365
|
+
attr_value_offset = compute_offset( parser->attr_value, parser->overflow_data );
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
// recompute mark, tag_text, attr_key, and attr_value as they all exist within data
|
|
369
|
+
mark_offset = compute_offset( parser->mark, data );
|
|
370
|
+
tag_text_offset = compute_offset( parser->tag_text, data );
|
|
371
|
+
attr_key_offset = compute_offset( parser->attr_key, data );
|
|
372
|
+
attr_value_offset = compute_offset( parser->attr_value, data );
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
if( parser->overflow_data ) {
|
|
376
|
+
// check if we need to resize or grow the buffer
|
|
377
|
+
if( (parser->overflow_data_size + length) > parser->overflow_data_allocated ) {
|
|
378
|
+
parser->overflow_data_allocated += length;
|
|
379
|
+
// printf( "realloc: %d bytes, using %d\n", (int)parser->overflow_data_allocated, (int)(parser->overflow_data_size+length) );
|
|
380
|
+
parser->overflow_data = (char*)realloc( parser->overflow_data, sizeof(char)*(parser->overflow_data_allocated) );
|
|
381
|
+
}
|
|
382
|
+
memcpy( parser->overflow_data+parser->overflow_data_size, data, length );
|
|
383
|
+
parser->overflow_data_size += length;
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
parser->overflow_data_allocated = ESI_OUTPUT_BUFFER_SIZE > length ? ESI_OUTPUT_BUFFER_SIZE : length;
|
|
387
|
+
parser->overflow_data = (char*)malloc( sizeof( char ) * parser->overflow_data_allocated );
|
|
388
|
+
memcpy( parser->overflow_data, data, length );
|
|
389
|
+
parser->overflow_data_size = length;
|
|
390
|
+
// printf( "malloc: %d for %d bytes\n", (int)parser->overflow_data_allocated, (int)length );
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// in our new memory space mark will now be
|
|
394
|
+
parser->mark = ( mark_offset >= 0 ) ? parser->overflow_data + mark_offset : NULL;
|
|
395
|
+
parser->tag_text = ( tag_text_offset >= 0 ) ? parser->overflow_data + tag_text_offset : NULL;
|
|
396
|
+
parser->attr_key = ( attr_key_offset >= 0 ) ? parser->overflow_data + attr_key_offset : NULL;
|
|
397
|
+
parser->attr_value = ( attr_value_offset >= 0 ) ? parser->overflow_data + attr_value_offset : NULL;
|
|
398
|
+
}
|
|
399
|
+
|
|
331
400
|
/* accept an arbitrary length string buffer
|
|
332
401
|
* when this methods exits it determines if an end state was reached
|
|
333
402
|
* if no end state was reached it saves the full input into an internal buffer
|
|
@@ -345,51 +414,33 @@ int esi_parser_execute( ESIParser *parser, const char *data, size_t length )
|
|
|
345
414
|
if( length == 0 ){ return cs; }
|
|
346
415
|
|
|
347
416
|
/* scan data for any '<esi:' start sequences, /<$/, /<e$/, /<es$/, /<esi$/, /<esi:$/ */
|
|
348
|
-
if( cs == esi_start ) {
|
|
417
|
+
if( cs == esi_start || cs == 0 ) {
|
|
349
418
|
pindex = esi_parser_scan_for_start( parser, data, length );
|
|
350
|
-
if( pindex == -1 ) {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
}
|
|
354
|
-
return cs;
|
|
419
|
+
if( pindex == -1 ) { /* this means there are no start sequences in the buffer we recieved */
|
|
420
|
+
esi_parser_send_buffer( parser, data, length );
|
|
421
|
+
return cs; /* no esi start sequences send it all out and break out early */
|
|
355
422
|
}
|
|
356
423
|
}
|
|
357
424
|
|
|
358
|
-
/* there's an existing overflow buffer
|
|
359
|
-
if( parser->overflow_data && parser->overflow_data_size > 0 ) {
|
|
425
|
+
/* there's an existing overflow buffer and it's being used, append the new data */
|
|
426
|
+
//if( parser->overflow_data && parser->overflow_data_size > 0 ) {
|
|
427
|
+
if( parser->using_overflow ) {
|
|
428
|
+
int prev_overflow_size = parser->overflow_data_size; // save the current overflow size
|
|
429
|
+
esi_parser_append_data_to_overflow_data( parser, data, length );
|
|
360
430
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
int tag_text_offset = compute_offset( parser->tag_text, parser->overflow_data );
|
|
364
|
-
int attr_key_offset = compute_offset( parser->attr_key, parser->overflow_data );
|
|
365
|
-
int attr_value_offset = compute_offset( parser->attr_value, parser->overflow_data );
|
|
366
|
-
|
|
367
|
-
parser->overflow_data = (char*)realloc( parser->overflow_data, sizeof(char)*(parser->overflow_data_size+length) );
|
|
368
|
-
memcpy( parser->overflow_data+parser->overflow_data_size, data, length );
|
|
369
|
-
|
|
370
|
-
p = parser->overflow_data + parser->overflow_data_size;
|
|
371
|
-
|
|
372
|
-
// in our new memory space mark will now be
|
|
373
|
-
parser->mark = ( mark_offset >= 0 ) ? parser->overflow_data + mark_offset : NULL;
|
|
374
|
-
parser->tag_text = ( tag_text_offset >= 0 ) ? parser->overflow_data + tag_text_offset : NULL;
|
|
375
|
-
parser->attr_key = ( attr_key_offset >= 0 ) ? parser->overflow_data + attr_key_offset : NULL;
|
|
376
|
-
parser->attr_value = ( attr_value_offset >= 0 ) ? parser->overflow_data + attr_value_offset : NULL;
|
|
377
|
-
|
|
431
|
+
/* set parser variables */
|
|
432
|
+
p = parser->overflow_data + prev_overflow_size;
|
|
378
433
|
data = parser->overflow_data;
|
|
379
|
-
|
|
380
|
-
// printf( "grow overflow data: %ld\n", parser->overflow_data_size );
|
|
434
|
+
length = parser->overflow_data_size;
|
|
381
435
|
pe = data + length;
|
|
382
|
-
|
|
383
436
|
}
|
|
384
437
|
|
|
385
438
|
if( !parser->mark ) {
|
|
386
439
|
parser->mark = p;
|
|
387
440
|
}
|
|
388
441
|
|
|
389
|
-
// printf( "cs: %d, ", cs );
|
|
390
|
-
|
|
391
442
|
|
|
392
|
-
#line
|
|
443
|
+
#line 444 "parser.c"
|
|
393
444
|
{
|
|
394
445
|
if ( p == pe )
|
|
395
446
|
goto _test_eof;
|
|
@@ -1303,7 +1354,7 @@ case 79:
|
|
|
1303
1354
|
tr98: cs = 79; goto f8;
|
|
1304
1355
|
|
|
1305
1356
|
f0:
|
|
1306
|
-
#line
|
|
1357
|
+
#line 295 "parser.rl"
|
|
1307
1358
|
{
|
|
1308
1359
|
//printf( "[%c:%d],", *p, cs );
|
|
1309
1360
|
switch( cs ) {
|
|
@@ -1330,7 +1381,7 @@ f0:
|
|
|
1330
1381
|
}
|
|
1331
1382
|
goto _again;
|
|
1332
1383
|
f1:
|
|
1333
|
-
#line
|
|
1384
|
+
#line 295 "parser.rl"
|
|
1334
1385
|
{
|
|
1335
1386
|
//printf( "[%c:%d],", *p, cs );
|
|
1336
1387
|
switch( cs ) {
|
|
@@ -1355,14 +1406,14 @@ f1:
|
|
|
1355
1406
|
*/
|
|
1356
1407
|
parser->prev_state = cs;
|
|
1357
1408
|
}
|
|
1358
|
-
#line
|
|
1409
|
+
#line 160 "parser.rl"
|
|
1359
1410
|
{
|
|
1360
1411
|
parser->mark = p;
|
|
1361
1412
|
//debug_string( "begin", p, 1 );
|
|
1362
1413
|
}
|
|
1363
1414
|
goto _again;
|
|
1364
1415
|
f10:
|
|
1365
|
-
#line
|
|
1416
|
+
#line 295 "parser.rl"
|
|
1366
1417
|
{
|
|
1367
1418
|
//printf( "[%c:%d],", *p, cs );
|
|
1368
1419
|
switch( cs ) {
|
|
@@ -1387,13 +1438,13 @@ f10:
|
|
|
1387
1438
|
*/
|
|
1388
1439
|
parser->prev_state = cs;
|
|
1389
1440
|
}
|
|
1390
|
-
#line
|
|
1441
|
+
#line 164 "parser.rl"
|
|
1391
1442
|
{
|
|
1392
1443
|
// printf( "finish\n" );
|
|
1393
1444
|
}
|
|
1394
1445
|
goto _again;
|
|
1395
1446
|
f3:
|
|
1396
|
-
#line
|
|
1447
|
+
#line 295 "parser.rl"
|
|
1397
1448
|
{
|
|
1398
1449
|
//printf( "[%c:%d],", *p, cs );
|
|
1399
1450
|
switch( cs ) {
|
|
@@ -1418,7 +1469,7 @@ f3:
|
|
|
1418
1469
|
*/
|
|
1419
1470
|
parser->prev_state = cs;
|
|
1420
1471
|
}
|
|
1421
|
-
#line
|
|
1472
|
+
#line 169 "parser.rl"
|
|
1422
1473
|
{
|
|
1423
1474
|
parser->tag_text = parser->mark+1;
|
|
1424
1475
|
parser->tag_text_length = p - (parser->mark+1);
|
|
@@ -1426,7 +1477,7 @@ f3:
|
|
|
1426
1477
|
}
|
|
1427
1478
|
goto _again;
|
|
1428
1479
|
f8:
|
|
1429
|
-
#line
|
|
1480
|
+
#line 295 "parser.rl"
|
|
1430
1481
|
{
|
|
1431
1482
|
//printf( "[%c:%d],", *p, cs );
|
|
1432
1483
|
switch( cs ) {
|
|
@@ -1451,7 +1502,7 @@ f8:
|
|
|
1451
1502
|
*/
|
|
1452
1503
|
parser->prev_state = cs;
|
|
1453
1504
|
}
|
|
1454
|
-
#line
|
|
1505
|
+
#line 176 "parser.rl"
|
|
1455
1506
|
{
|
|
1456
1507
|
/* trim the tag text */
|
|
1457
1508
|
ltrim_pointer( &(parser->tag_text), p, &(parser->tag_text_length) );
|
|
@@ -1460,9 +1511,8 @@ f8:
|
|
|
1460
1511
|
/* send the start tag and end tag message */
|
|
1461
1512
|
esi_parser_flush_output( parser );
|
|
1462
1513
|
parser->start_tag_handler( data, parser->tag_text, parser->tag_text_length, parser->attributes, parser->user_data );
|
|
1463
|
-
esi_parser_flush_output( parser );
|
|
1464
1514
|
parser->end_tag_handler( data, parser->tag_text, parser->tag_text_length, parser->user_data );
|
|
1465
|
-
|
|
1515
|
+
//printf("\t[see inline tag]\n");
|
|
1466
1516
|
|
|
1467
1517
|
/* mark the position */
|
|
1468
1518
|
parser->tag_text = NULL;
|
|
@@ -1474,7 +1524,7 @@ f8:
|
|
|
1474
1524
|
}
|
|
1475
1525
|
goto _again;
|
|
1476
1526
|
f5:
|
|
1477
|
-
#line
|
|
1527
|
+
#line 295 "parser.rl"
|
|
1478
1528
|
{
|
|
1479
1529
|
//printf( "[%c:%d],", *p, cs );
|
|
1480
1530
|
switch( cs ) {
|
|
@@ -1499,7 +1549,7 @@ f5:
|
|
|
1499
1549
|
*/
|
|
1500
1550
|
parser->prev_state = cs;
|
|
1501
1551
|
}
|
|
1502
|
-
#line
|
|
1552
|
+
#line 197 "parser.rl"
|
|
1503
1553
|
{
|
|
1504
1554
|
/* trim tag text */
|
|
1505
1555
|
ltrim_pointer( &(parser->tag_text), p, &(parser->tag_text_length) );
|
|
@@ -1508,7 +1558,7 @@ f5:
|
|
|
1508
1558
|
/* send the start and end tag message */
|
|
1509
1559
|
esi_parser_flush_output( parser );
|
|
1510
1560
|
parser->start_tag_handler( data, parser->tag_text, parser->tag_text_length, parser->attributes, parser->user_data );
|
|
1511
|
-
|
|
1561
|
+
//printf("\t[see start tag with attributes]\n");
|
|
1512
1562
|
|
|
1513
1563
|
parser->tag_text = NULL;
|
|
1514
1564
|
parser->tag_text_length = 0;
|
|
@@ -1519,7 +1569,7 @@ f5:
|
|
|
1519
1569
|
}
|
|
1520
1570
|
goto _again;
|
|
1521
1571
|
f6:
|
|
1522
|
-
#line
|
|
1572
|
+
#line 295 "parser.rl"
|
|
1523
1573
|
{
|
|
1524
1574
|
//printf( "[%c:%d],", *p, cs );
|
|
1525
1575
|
switch( cs ) {
|
|
@@ -1544,7 +1594,7 @@ f6:
|
|
|
1544
1594
|
*/
|
|
1545
1595
|
parser->prev_state = cs;
|
|
1546
1596
|
}
|
|
1547
|
-
#line
|
|
1597
|
+
#line 216 "parser.rl"
|
|
1548
1598
|
{
|
|
1549
1599
|
/* save the attribute key start */
|
|
1550
1600
|
parser->attr_key = parser->mark;
|
|
@@ -1559,7 +1609,7 @@ f6:
|
|
|
1559
1609
|
}
|
|
1560
1610
|
goto _again;
|
|
1561
1611
|
f7:
|
|
1562
|
-
#line
|
|
1612
|
+
#line 295 "parser.rl"
|
|
1563
1613
|
{
|
|
1564
1614
|
//printf( "[%c:%d],", *p, cs );
|
|
1565
1615
|
switch( cs ) {
|
|
@@ -1584,7 +1634,7 @@ f7:
|
|
|
1584
1634
|
*/
|
|
1585
1635
|
parser->prev_state = cs;
|
|
1586
1636
|
}
|
|
1587
|
-
#line
|
|
1637
|
+
#line 230 "parser.rl"
|
|
1588
1638
|
{
|
|
1589
1639
|
ESIAttribute *attr;
|
|
1590
1640
|
|
|
@@ -1614,7 +1664,7 @@ f7:
|
|
|
1614
1664
|
}
|
|
1615
1665
|
goto _again;
|
|
1616
1666
|
f4:
|
|
1617
|
-
#line
|
|
1667
|
+
#line 295 "parser.rl"
|
|
1618
1668
|
{
|
|
1619
1669
|
//printf( "[%c:%d],", *p, cs );
|
|
1620
1670
|
switch( cs ) {
|
|
@@ -1639,7 +1689,7 @@ f4:
|
|
|
1639
1689
|
*/
|
|
1640
1690
|
parser->prev_state = cs;
|
|
1641
1691
|
}
|
|
1642
|
-
#line
|
|
1692
|
+
#line 259 "parser.rl"
|
|
1643
1693
|
{
|
|
1644
1694
|
|
|
1645
1695
|
parser->tag_text = parser->mark;
|
|
@@ -1652,13 +1702,13 @@ f4:
|
|
|
1652
1702
|
|
|
1653
1703
|
esi_parser_flush_output( parser );
|
|
1654
1704
|
parser->start_tag_handler( data, parser->tag_text, parser->tag_text_length, NULL, parser->user_data );
|
|
1655
|
-
|
|
1705
|
+
//printf("\t[see start tag]\n");
|
|
1656
1706
|
|
|
1657
1707
|
esi_parser_echobuffer_clear( parser );
|
|
1658
1708
|
}
|
|
1659
1709
|
goto _again;
|
|
1660
1710
|
f2:
|
|
1661
|
-
#line
|
|
1711
|
+
#line 295 "parser.rl"
|
|
1662
1712
|
{
|
|
1663
1713
|
//printf( "[%c:%d],", *p, cs );
|
|
1664
1714
|
switch( cs ) {
|
|
@@ -1683,7 +1733,7 @@ f2:
|
|
|
1683
1733
|
*/
|
|
1684
1734
|
parser->prev_state = cs;
|
|
1685
1735
|
}
|
|
1686
|
-
#line
|
|
1736
|
+
#line 277 "parser.rl"
|
|
1687
1737
|
{
|
|
1688
1738
|
/* offset by 2 to account for the </ characters */
|
|
1689
1739
|
parser->tag_text = parser->mark+2;
|
|
@@ -1696,13 +1746,13 @@ f2:
|
|
|
1696
1746
|
|
|
1697
1747
|
esi_parser_flush_output( parser );
|
|
1698
1748
|
parser->end_tag_handler( data, parser->tag_text, parser->tag_text_length, parser->user_data );
|
|
1699
|
-
|
|
1749
|
+
//printf("\t[see end tag]\n");
|
|
1700
1750
|
|
|
1701
1751
|
esi_parser_echobuffer_clear( parser );
|
|
1702
1752
|
}
|
|
1703
1753
|
goto _again;
|
|
1704
1754
|
f12:
|
|
1705
|
-
#line
|
|
1755
|
+
#line 295 "parser.rl"
|
|
1706
1756
|
{
|
|
1707
1757
|
//printf( "[%c:%d],", *p, cs );
|
|
1708
1758
|
switch( cs ) {
|
|
@@ -1727,18 +1777,18 @@ f12:
|
|
|
1727
1777
|
*/
|
|
1728
1778
|
parser->prev_state = cs;
|
|
1729
1779
|
}
|
|
1730
|
-
#line
|
|
1780
|
+
#line 160 "parser.rl"
|
|
1731
1781
|
{
|
|
1732
1782
|
parser->mark = p;
|
|
1733
1783
|
//debug_string( "begin", p, 1 );
|
|
1734
1784
|
}
|
|
1735
|
-
#line
|
|
1785
|
+
#line 164 "parser.rl"
|
|
1736
1786
|
{
|
|
1737
1787
|
// printf( "finish\n" );
|
|
1738
1788
|
}
|
|
1739
1789
|
goto _again;
|
|
1740
1790
|
f11:
|
|
1741
|
-
#line
|
|
1791
|
+
#line 295 "parser.rl"
|
|
1742
1792
|
{
|
|
1743
1793
|
//printf( "[%c:%d],", *p, cs );
|
|
1744
1794
|
switch( cs ) {
|
|
@@ -1763,7 +1813,7 @@ f11:
|
|
|
1763
1813
|
*/
|
|
1764
1814
|
parser->prev_state = cs;
|
|
1765
1815
|
}
|
|
1766
|
-
#line
|
|
1816
|
+
#line 230 "parser.rl"
|
|
1767
1817
|
{
|
|
1768
1818
|
ESIAttribute *attr;
|
|
1769
1819
|
|
|
@@ -1791,7 +1841,7 @@ f11:
|
|
|
1791
1841
|
parser->last = parser->attributes = attr;
|
|
1792
1842
|
}
|
|
1793
1843
|
}
|
|
1794
|
-
#line
|
|
1844
|
+
#line 164 "parser.rl"
|
|
1795
1845
|
{
|
|
1796
1846
|
// printf( "finish\n" );
|
|
1797
1847
|
}
|
|
@@ -1805,54 +1855,30 @@ _again:
|
|
|
1805
1855
|
{
|
|
1806
1856
|
switch ( _esi_eof_actions[cs] ) {
|
|
1807
1857
|
case 10:
|
|
1808
|
-
#line
|
|
1858
|
+
#line 164 "parser.rl"
|
|
1809
1859
|
{
|
|
1810
1860
|
// printf( "finish\n" );
|
|
1811
1861
|
}
|
|
1812
1862
|
break;
|
|
1813
|
-
#line
|
|
1863
|
+
#line 1864 "parser.c"
|
|
1814
1864
|
}
|
|
1815
1865
|
}
|
|
1816
1866
|
|
|
1817
1867
|
}
|
|
1818
|
-
#line
|
|
1868
|
+
#line 579 "parser.rl"
|
|
1819
1869
|
|
|
1820
1870
|
parser->cs = cs;
|
|
1821
1871
|
|
|
1822
1872
|
if( cs != esi_start && cs != 0 ) {
|
|
1823
1873
|
|
|
1824
1874
|
/* reached the end and we're not at a termination point save the buffer as overflow */
|
|
1825
|
-
if( !parser->
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
int tag_text_offset = compute_offset( parser->tag_text, data );
|
|
1829
|
-
int attr_key_offset = compute_offset( parser->attr_key, data );
|
|
1830
|
-
int attr_value_offset = compute_offset( parser->attr_value, data );
|
|
1831
|
-
//debug_string( "mark before move", parser->mark, 1 );
|
|
1832
|
-
|
|
1833
|
-
if( ESI_OUTPUT_BUFFER_SIZE > length ) {
|
|
1834
|
-
parser->echobuffer_allocated = ESI_OUTPUT_BUFFER_SIZE;
|
|
1835
|
-
}
|
|
1836
|
-
else {
|
|
1837
|
-
parser->echobuffer_allocated = length;
|
|
1838
|
-
}
|
|
1839
|
-
parser->overflow_data = (char*)malloc( sizeof( char ) * parser->echobuffer_allocated );
|
|
1840
|
-
memcpy( parser->overflow_data, data, length );
|
|
1841
|
-
parser->overflow_data_size = length;
|
|
1842
|
-
//printf( "allocate overflow data: %ld\n", parser->echobuffer_allocated );
|
|
1843
|
-
|
|
1844
|
-
// in our new memory space mark will now be
|
|
1845
|
-
parser->mark = ( mark_offset >= 0 ) ? parser->overflow_data + mark_offset : NULL;
|
|
1846
|
-
parser->tag_text = ( tag_text_offset >= 0 ) ? parser->overflow_data + tag_text_offset : NULL;
|
|
1847
|
-
parser->attr_key = ( attr_key_offset >= 0 ) ? parser->overflow_data + attr_key_offset : NULL;
|
|
1848
|
-
parser->attr_value = ( attr_value_offset >= 0 ) ? parser->overflow_data + attr_value_offset : NULL;
|
|
1849
|
-
//if( parser->mark ){ debug_string( "mark after move", parser->mark, 1 ); } else { printf( "mark is now empty\n" ); }
|
|
1875
|
+
if( !parser->using_overflow ) {
|
|
1876
|
+
esi_parser_append_data_to_overflow_data( parser, data, length );
|
|
1877
|
+
parser->using_overflow = 1;
|
|
1850
1878
|
}
|
|
1851
1879
|
|
|
1852
|
-
}else if( parser->
|
|
1853
|
-
|
|
1854
|
-
free( parser->overflow_data );
|
|
1855
|
-
parser->overflow_data = NULL;
|
|
1880
|
+
} else if ( parser->using_overflow ) {
|
|
1881
|
+
parser->using_overflow = 0;
|
|
1856
1882
|
parser->overflow_data_size = 0;
|
|
1857
1883
|
}
|
|
1858
1884
|
|