public
Rubygem
Description: A very fast & simple Ruby web server
Homepage: http://code.macournoyer.com/thin/
Clone URL: git://github.com/macournoyer/thin.git
Click here to lend your support to: thin and make a donation at www.pledgie.com !
Defaults SERVER_NAME to localhost like webrick does [#87 state:resolved]
macournoyer (author)
Tue Dec 16 18:05:54 -0800 2008
commit  7c8e416848e2dfc8f1fb594997be640cf8f398b2
tree    7571731c2546d62021493999734293f618c70d64
parent  6ac518fe765517fc0b5b39ce5d72bf6671f0a1eb
...
1
 
2
3
4
...
1
2
3
4
5
0
@@ -1,4 +1,5 @@
0
 == 1.0.1 ? release
0
+ * Defaults SERVER_NAME to localhost like webrick does [#87 state:resolved]
0
  * Namespace parser to prevent error when mongrel is required [cliffmoon]
0
  * Set RACK_ENV based on environment option when loading rackup file [Curtis Summers] [#83 state:resolved]
0
  * Fixes a warning RE relative_url_root when using a prefix with Rails 2.1.1 [seriph] [#85 state:resolved]
...
16
17
18
 
 
19
20
21
...
49
50
51
 
52
53
54
...
16
17
18
19
20
21
22
23
...
51
52
53
54
55
56
57
0
@@ -16,6 +16,8 @@ module Thin
0
 
0
     # Freeze some HTTP header names & values
0
     SERVER_SOFTWARE   = 'SERVER_SOFTWARE'.freeze
0
+    SERVER_NAME       = 'SERVER_NAME'.freeze
0
+    LOCALHOST         = 'localhost'.freeze
0
     HTTP_VERSION      = 'HTTP_VERSION'.freeze
0
     HTTP_1_0          = 'HTTP/1.0'.freeze
0
     REMOTE_ADDR       = 'REMOTE_ADDR'.freeze
0
@@ -49,6 +51,7 @@ module Thin
0
       @body     = StringIO.new
0
       @env      = {
0
         SERVER_SOFTWARE   => SERVER,
0
+        SERVER_NAME       => LOCALHOST,
0
 
0
         # Rack stuff
0
         RACK_INPUT        => @body,
...
59
60
61
62
 
63
64
65
...
70
71
72
73
74
 
 
75
76
77
...
195
196
197
 
 
 
 
 
198
199
...
59
60
61
 
62
63
64
65
...
70
71
72
 
 
73
74
75
76
77
...
195
196
197
198
199
200
201
202
203
204
0
@@ -59,7 +59,7 @@ describe Request, 'parser' do
0
   it 'should parse headers from GET request' do
0
     request = R(<<-EOS, true)
0
 GET / HTTP/1.1
0
-Host: localhost:3000
0
+Host: myhost.com:3000
0
 User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9
0
 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
0
 Accept-Language: en-us,en;q=0.5
0
@@ -70,8 +70,8 @@ Keep-Alive: 300
0
 Connection: keep-alive
0
 
0
 EOS
0
-    request.env['HTTP_HOST'].should == 'localhost:3000'
0
-    request.env['SERVER_NAME'].should == 'localhost'
0
+    request.env['HTTP_HOST'].should == 'myhost.com:3000'
0
+    request.env['SERVER_NAME'].should == 'myhost.com'
0
     request.env['SERVER_PORT'].should == '3000'
0
     request.env['HTTP_COOKIE'].should == 'mium=7'
0
 
0
@@ -195,4 +195,9 @@ EOS
0
   it "should fails on heders larger then MAX_HEADER" do
0
     proc { R("GET / HTTP/1.1\r\nFoo: #{'X' * Request::MAX_HEADER}\r\n\r\n") }.should raise_error(InvalidRequest)
0
   end
0
+  
0
+  it "should default SERVER_NAME to localhost" do
0
+    request = R("GET / HTTP/1.1\r\n\r\n")
0
+    request.env['SERVER_NAME'].should == "localhost"
0
+  end
0
 end
0
\ No newline at end of file

Comments