public
Description: A very fast & simple Ruby web server
Homepage: http://code.macournoyer.com/thin/
Clone URL: git://github.com/macournoyer/thin.git
Search Repo:
Details doc and add some users to the site
macournoyer (author)
Fri Jan 11 19:01:05 -0800 2008
commit  85cebaef4bfe0589592913815ae351e9ec551312
tree    76a9bce3eefd536a99576c9e34b467cada462113
parent  1631181287baa0f7249a802924c31501793cae55
0
...
14
15
16
 
...
14
15
16
17
0
@@ -14,4 +14,5 @@
0
  * Port response writing to a C extension
0
  * Benchmark CGI and FastCGI too [Carlos Junior]
0
  * Investigate http://rev.rubyforge.org/
0
+ * Check for memory leaks using dike and Instruments
...
5
6
7
 
8
9
10
11
12
13
...
47
48
49
50
 
51
52
 
53
54
 
55
56
57
58
59
60
61
 
62
63
64
...
5
6
7
8
9
10
11
12
13
14
...
48
49
50
 
51
52
 
53
54
 
55
56
57
58
59
60
61
 
62
63
64
65
0
@@ -5,6 +5,7 @@
0
   # and the server can not process it.
0
   class InvalidRequest < IOError; end
0
   
0
+ # A request sent by the client to the server.
0
   class Request
0
     MAX_HEADER = 1024 * (80 + 32)
0
     MAX_HEADER_MSG = 'Header longer than allowed'.freeze
0
0
0
0
@@ -47,18 +48,18 @@
0
     def parse(data)
0
       @data << data
0
       
0
- if @parser.finished? # Header finished, can only be some more body
0
+ if @parser.finished? # Header finished, can only be some more body
0
         body << data
0
- elsif @data.size > MAX_HEADER
0
+ elsif @data.size > MAX_HEADER # Oho! very big header, must be a bad person
0
        raise InvalidRequest, MAX_HEADER_MSG
0
- else # Parse more header
0
+ else # Parse more header
0
        @nparsed = @parser.execute(@env, @data, @nparsed)
0
       end
0
       
0
       # Check if header and body are complete
0
       if @parser.finished? && body.size >= content_length
0
      body.rewind
0
- return true
0
+ return true # Request is fully parsed
0
      end
0
       
0
       false # Not finished, need more data
...
4
5
6
7
8
9
 
 
 
10
11
12
...
18
19
20
21
 
22
23
24
...
65
66
67
 
68
69
70
...
4
5
6
 
 
 
7
8
9
10
11
12
...
18
19
20
 
21
22
23
24
...
65
66
67
68
69
70
71
0
@@ -4,9 +4,9 @@
0
   
0
   # The Thin HTTP server used to served request.
0
   # It listen for incoming request on a given port
0
- # and forward all request to all the handlers in the order
0
- # they were registered.
0
- # Based on HTTP 1.1 protocol specs
0
+ # and forward all request to +app+.
0
+ #
0
+ # Based on HTTP 1.1 protocol specs:
0
   # http://www.w3.org/Protocols/rfc2616/rfc2616.html
0
   class Server
0
     include Logging
0
@@ -18,7 +18,7 @@
0
     # App called with the request that produce the response.
0
     attr_accessor :app
0
     
0
- # Maximum time for a request to be red and parsed.
0
+ # Maximum time for incoming data to arrive
0
     attr_accessor :timeout
0
     
0
     # Creates a new server binded to <tt>host:port</tt>
0
@@ -65,6 +65,7 @@
0
         end
0
       end
0
     end
0
+
0
     
0
     def stop
0
       EventMachine.stop_event_loop
...
137
138
139
 
140
141
142
...
137
138
139
140
141
142
143
0
@@ -137,6 +137,7 @@
0
       li { a "Joao Pedrosa's Blog", :href => 'http://www.deze9.com/jp/blog/post?p=enabling-thin-support-for-this-site-replacing' }
0
       li { a "Kevin Williams Blog", :href => 'http://www.almostserio.us/articles/2008/01/11/thin-web-server-for-ruby-rocks' }
0
       li { a "Dinooz", :href => 'http://www.nicomoayudarte.com/' }
0
+ li { a "Mobile Dyne Systems", :href => 'http://www.mobiledyne.com/' }
0
     end
0
     
0
     p { "If you'd like to have your site listed here, #{a 'drop me an email', :href => 'mailto:macournoyer@gmail.com'}" }

Comments

    No one has commented yet.