Changeset 331
- Timestamp:
- 08/16/06 16:51:38 (2 years ago)
- Files:
-
- trunk/Rakefile (modified) (1 diff)
- trunk/ext/http11/http11_parser.c (modified) (17 diffs)
- trunk/ext/http11/http11_parser.rl (modified) (1 diff)
- trunk/lib/mongrel.rb (modified) (2 diffs)
- trunk/lib/mongrel/configurator.rb (modified) (1 diff)
- trunk/test/test_http11.rb (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Rakefile
r326 r331 88 88 sub_project("mongrel_upload_progress", :install) 89 89 sub_project("mongrel_console", :install) 90 sub_project("mongrel_cluster", :install) 90 91 if RUBY_PLATFORM =~ /mswin/ 91 92 sub_project("mongrel_service", :install) trunk/ext/http11/http11_parser.c
r318 r331 181 181 } 182 182 goto st5; 183 tr40: 184 #line 43 "ext/http11/http11_parser.rl" 185 {MARK(query_start, p); } 186 #line 44 "ext/http11/http11_parser.rl" 187 { 188 if(parser->query_string != NULL) 189 parser->query_string(parser->data, PTR_TO(query_start), LEN(query_start, p)); 190 } 191 #line 38 "ext/http11/http11_parser.rl" 192 { 193 if(parser->request_uri != NULL) 194 parser->request_uri(parser->data, PTR_TO(mark), LEN(mark, p)); 195 } 196 goto st5; 183 197 st5: 184 198 if ( ++p == pe ) 185 199 goto _out5; 186 200 case 5: 187 #line 188"ext/http11/http11_parser.c"201 #line 202 "ext/http11/http11_parser.c" 188 202 if ( (*p) == 72 ) 189 203 goto tr3; … … 197 211 goto _out6; 198 212 case 6: 199 #line 2 00"ext/http11/http11_parser.c"213 #line 214 "ext/http11/http11_parser.c" 200 214 if ( (*p) == 84 ) 201 215 goto st7; … … 273 287 goto _out14; 274 288 case 14: 275 #line 2 76"ext/http11/http11_parser.c"289 #line 290 "ext/http11/http11_parser.c" 276 290 if ( (*p) == 10 ) 277 291 goto st15; … … 325 339 goto _out53; 326 340 case 53: 327 #line 3 28"ext/http11/http11_parser.c"341 #line 342 "ext/http11/http11_parser.c" 328 342 goto st1; 329 343 tr21: … … 335 349 goto _out17; 336 350 case 17: 337 #line 3 38"ext/http11/http11_parser.c"351 #line 352 "ext/http11/http11_parser.c" 338 352 switch( (*p) ) { 339 353 case 33: goto st17; … … 374 388 goto _out18; 375 389 case 18: 376 #line 3 77"ext/http11/http11_parser.c"390 #line 391 "ext/http11/http11_parser.c" 377 391 switch( (*p) ) { 378 392 case 13: goto tr36; … … 388 402 goto _out19; 389 403 case 19: 390 #line 391"ext/http11/http11_parser.c"404 #line 405 "ext/http11/http11_parser.c" 391 405 if ( (*p) == 13 ) 392 406 goto tr36; … … 400 414 goto _out20; 401 415 case 20: 402 #line 4 03"ext/http11/http11_parser.c"416 #line 417 "ext/http11/http11_parser.c" 403 417 switch( (*p) ) { 404 418 case 43: goto st20; … … 425 439 goto _out21; 426 440 case 21: 427 #line 4 28"ext/http11/http11_parser.c"441 #line 442 "ext/http11/http11_parser.c" 428 442 switch( (*p) ) { 429 443 case 32: goto tr19; … … 473 487 goto _out24; 474 488 case 24: 475 #line 4 76"ext/http11/http11_parser.c"489 #line 490 "ext/http11/http11_parser.c" 476 490 switch( (*p) ) { 477 491 case 32: goto tr31; … … 526 540 goto _out27; 527 541 case 27: 528 #line 5 29"ext/http11/http11_parser.c"542 #line 543 "ext/http11/http11_parser.c" 529 543 switch( (*p) ) { 530 544 case 32: goto tr19; … … 578 592 goto _out30; 579 593 case 30: 580 #line 5 81"ext/http11/http11_parser.c"581 switch( (*p) ) { 582 case 32: goto tr 28;583 case 37: goto tr4 0;594 #line 595 "ext/http11/http11_parser.c" 595 switch( (*p) ) { 596 case 32: goto tr40; 597 case 37: goto tr41; 584 598 case 60: goto st1; 585 599 case 62: goto st1; … … 600 614 goto _out31; 601 615 case 31: 602 #line 6 03"ext/http11/http11_parser.c"616 #line 617 "ext/http11/http11_parser.c" 603 617 switch( (*p) ) { 604 618 case 32: goto tr28; … … 614 628 goto st1; 615 629 goto st31; 616 tr4 0:630 tr41: 617 631 #line 43 "ext/http11/http11_parser.rl" 618 632 {MARK(query_start, p); } … … 622 636 goto _out32; 623 637 case 32: 624 #line 6 25"ext/http11/http11_parser.c"638 #line 639 "ext/http11/http11_parser.c" 625 639 if ( (*p) < 65 ) { 626 640 if ( 48 <= (*p) && (*p) <= 57 ) … … 1048 1062 /* final \r\n combo encountered so stop right here */ 1049 1063 1050 #line 10 51"ext/http11/http11_parser.c"1064 #line 1065 "ext/http11/http11_parser.c" 1051 1065 #line 163 "ext/http11/http11_parser.rl" 1052 1066 parser->nread++; … … 1061 1075 1062 1076 1063 #line 10 64"ext/http11/http11_parser.c"1077 #line 1078 "ext/http11/http11_parser.c" 1064 1078 #line 174 "ext/http11/http11_parser.rl" 1065 1079 trunk/ext/http11/http11_parser.rl
r312 r331 90 90 91 91 path = (pchar+ ( "/" pchar* )*) ; 92 query = ( uchar | reserved )* >start_query%query_string ;92 query = ( uchar | reserved )* %query_string ; 93 93 param = ( pchar | "/" )* ; 94 94 params = (param ( ";" param )*) ; 95 rel_path = (path? %request_path (";" params)?) ("?" query)?;95 rel_path = (path? %request_path (";" params)?) ("?" %start_query query)?; 96 96 absolute_path = ("/"+ rel_path); 97 97 trunk/lib/mongrel.rb
r329 r331 4 4 # Additional work donated by contributors. See http://mongrel.rubyforge.org/attributions.html 5 5 # for more information. 6 7 $mongrel_debug_client = false 6 8 7 9 require 'socket' … … 586 588 rescue HttpParserError 587 589 STDERR.puts "#{Time.now}: BAD CLIENT (#{params[Const::HTTP_X_FORWARDED_FOR] || client.peeraddr.last}): #$!" 590 if $mongrel_debug_client 591 STDERR.puts "#{Time.now}: REQUEST DATA: #{data.inspect}\n---\nPARAMS: #{params.inspect}\n---\n" 592 end 588 593 rescue Errno::EMFILE 589 594 reap_dead_workers('too many files') 590 595 rescue Object 591 596 STDERR.puts "#{Time.now}: ERROR: #$!" 592 STDERR.puts $!.backtrace.join("\n") 597 STDERR.puts $!.backtrace.join("\n") if $mongrel_debug_client 593 598 ensure 594 599 client.close rescue Object trunk/lib/mongrel/configurator.rb
r320 r331 357 357 # graceful shutdown 358 358 trap("TERM") { log "TERM signal received."; stop } 359 359 trap("USR1") { log "USR1 received, toggling $mongrel_debug_client to #{!$mongrel_debug_client}"; $mongrel_debug_client = !$mongrel_debug_client } 360 360 # restart 361 361 trap("USR2") { log "USR2 signal received."; stop(true) } trunk/test/test_http11.rb
r318 r331 61 61 62 62 if readable 63 res << Digest::SHA1.hexdigest(rand(count * 100 0).to_s) * (count / 40)63 res << Digest::SHA1.hexdigest(rand(count * 100).to_s) * (count / 40) 64 64 else 65 res << Digest::SHA1.digest(rand(count * 100 0).to_s) * (count / 20)65 res << Digest::SHA1.digest(rand(count * 100).to_s) * (count / 20) 66 66 end 67 67 … … 73 73 parser = HttpParser.new 74 74 75 # first verify that large random get requests fail76 100.times do |c|77 get = "GET /#{rand_data(1024, 1024+(c*1024))} HTTP/1.1\r\n"78 assert_raises Mongrel::HttpParserError do79 parser.execute({}, get, 0)80 parser.reset81 end82 end83 84 75 # then that large header names are caught 85 10 0.times do |c|76 10.times do |c| 86 77 get = "GET /#{rand_data(10,120)} HTTP/1.1\r\nX-#{rand_data(1024, 1024+(c*1024))}: Test\r\n\r\n" 87 78 assert_raises Mongrel::HttpParserError do … … 92 83 93 84 # then that large mangled field values are caught 94 10 0.times do |c|85 10.times do |c| 95 86 get = "GET /#{rand_data(10,120)} HTTP/1.1\r\nX-Test: #{rand_data(1024, 1024+(c*1024), false)}\r\n\r\n" 96 87 assert_raises Mongrel::HttpParserError do
