yahns 1.3.1 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 164544a63a17cfe2b98fb72ad88372ef172e1f36
4
- data.tar.gz: 70a7cf50db77f1297f1ea551b18037ae664e3d25
3
+ metadata.gz: 689a07f3155677900ad1b3df449a06978c2edd8c
4
+ data.tar.gz: 6741406d0b136e70745bc5aa728f6f5f7faa77bc
5
5
  SHA512:
6
- metadata.gz: cd3e8a33edf8edfdc912d66146234605be0c086d7d80eddb9c01bb9a93fa49e1fb9936b08f2ce2abe3e4ab3cad2405c4224ba6f9cdf400d25f6d0d67a8d82391
7
- data.tar.gz: fc2d66c05bba3f5bc21d99d5e015801d7f43d2f8c20cd105507b49c5fe8c1e0a86c562b1e183ab25b2d63b785af77f712a330b50714120598e02065073e8b15d
6
+ metadata.gz: b17db2fead5e7ff7585fdd5433f0adb43b247a46502ac99b7530bdc7b8a0d5e96b8d45a238ab7f16f8438ccac38a1cd1aaac33db1d55dcfbc1fbd034f6d2c203
7
+ data.tar.gz: 8fe3e364ff37d704d40079657d14739f9ac3fe886ffc86e6bc22bc606162ab906370279ba6a1f7d312c7acdc4f6f07269e655ab42ff55698f8a1adb5956e4ae2
data/GIT-VERSION-GEN CHANGED
@@ -4,7 +4,7 @@
4
4
  CONSTANT = "Yahns::VERSION"
5
5
  RVF = "lib/yahns/version.rb"
6
6
  GVF = "GIT-VERSION-FILE"
7
- DEF_VER = "v1.3.1"
7
+ DEF_VER = "v1.4.0"
8
8
  vn = DEF_VER
9
9
 
10
10
  # First see if there is a version file (included in release tarballs),
data/README CHANGED
@@ -82,7 +82,7 @@ Hacking
82
82
  We use git and follow the same development model as git itself
83
83
  (mailing list-oriented, benevolent dictator).
84
84
 
85
- git clone git://yhbt.net/yahns
85
+ git clone git://yhbt.net/yahns
86
86
 
87
87
  Please use git-format-patch(1) and git-send-email(1) distributed with
88
88
  the git(7) suite for generating and sending patches. Please format
@@ -94,7 +94,7 @@ See http://www.git-scm.com/ for more information on git.
94
94
  Design
95
95
  ------
96
96
 
97
- yahns is designed to optimimally use multiple threads with non-blocking I/O.
97
+ yahns is designed to optimally use multiple threads with non-blocking I/O.
98
98
  The event loop is not a traditional single-threaded design with a mutex
99
99
  slapped on as an afterthought, but designed from the beginning to utilize
100
100
  multiple threads.
@@ -109,16 +109,16 @@ multiple threads.
109
109
  The end result is clients transition freely and fairly between threads
110
110
  and will always be able to find the next idle thread to run on.
111
111
 
112
- This design works with kqueue, too, and we will support kqueue if there
113
- is interest. In fact, got our design inspiration from the name "kqueue"
114
- when working on another project. We may also support libkqueue:
112
+ This design works with kqueue, too, and we support kqueue. In fact, got
113
+ our design inspiration from the name "kqueue" when working on another
114
+ project. We may also support libkqueue:
115
115
 
116
116
  http://sourceforge.net/projects/libkqueue/
117
117
 
118
118
  In addition to multiple threads, yahns optionally supports multiple
119
119
  processes to work around low FD limits as well as contention in the:
120
120
 
121
- * kernel (socket (de)allocation from accept/close)
121
+ * kernel (socket (de)allocation from accept/close, mmap/sbrk locks)
122
122
  * standard C library (malloc/free)
123
123
  * Ruby VM (GVL, GC)
124
124
  * application it hosts
@@ -126,7 +126,7 @@ processes to work around low FD limits as well as contention in the:
126
126
  Copyright
127
127
  ---------
128
128
 
129
- Copyright 2013, Eric Wong <normalperson@yhbt.net> and all contributors.
129
+ Copyright 2013-2014, all contributors (see git repo).
130
130
  License: GPLv3 or later <https://www.gnu.org/licenses/gpl-3.0.txt>
131
131
 
132
132
  yahns is copyrighted Free Software by all contributors, see logs in
@@ -147,4 +147,15 @@ for more details.
147
147
  You should have received a copy of the GNU General Public License along
148
148
  with this program; if not, see https://www.gnu.org/licenses/gpl-3.0.txt
149
149
 
150
+ Additional permission under GNU GPL version 3 section 7:
151
+
152
+ If you modify this program, or any covered work, by linking or
153
+ combining it with the OpenSSL project's OpenSSL library (or a
154
+ modified version of that library), containing parts covered by the
155
+ terms of the OpenSSL or SSLeay licenses, the copyright holder(s)
156
+ grants you additional permission to convey the resulting work.
157
+ Corresponding Source for a non-source form of such a combination
158
+ shall include the source code for the parts of OpenSSL used as well
159
+ as that of the covered work.
160
+
150
161
  lrg nabgure ubeevoyl-anzrq freire :>
data/extras/autoindex.rb CHANGED
@@ -13,12 +13,13 @@ class Autoindex
13
13
  FN = %{<a href="%s">%s</a>}
14
14
  TFMT = "%Y-%m-%d %H:%M"
15
15
 
16
- def initialize(app, index = %w(index.html))
16
+ def initialize(app, index = %w(index.html), skip_gzip_static = true)
17
17
  app.respond_to?(:root) or raise ArgumentError,
18
18
  "wrapped app #{app.inspect} does not respond to :root"
19
19
  @app = app
20
20
  @root = app.root
21
21
  @index = index
22
+ @skip_gz = skip_gzip_static
22
23
  end
23
24
 
24
25
  def redirect_slash(env)
@@ -67,10 +68,13 @@ class Autoindex
67
68
  # generate the index, show directories first
68
69
  dirs = []
69
70
  files = []
71
+ ngz_idx = {} if @skip_gz # used to avoid redundant stat()
70
72
  dir.each do |base|
71
73
  case base
72
74
  when "."
73
75
  next
76
+ when ".."
77
+ next if path_info == "/"
74
78
  end
75
79
 
76
80
  begin
@@ -90,8 +94,22 @@ class Autoindex
90
94
  entry << (" " * pad) if pad > 0
91
95
  entry << st.mtime.strftime(TFMT)
92
96
  entry << sprintf("% 8s", human_size(st))
97
+ entry = [name, entry]
93
98
 
94
- (st.directory? ? dirs : files) << [ name, entry ]
99
+ if st.directory?
100
+ dirs << entry
101
+ elsif ngz_idx
102
+ ngz_idx[name] = entry
103
+ else
104
+ files << entry
105
+ end
106
+ end
107
+
108
+ if ngz_idx
109
+ ngz_idx.each do |name, entry|
110
+ ngz_path = name.dup.gsub!(/\.gz\z/, '')
111
+ ngz_idx.include?(ngz_path) or files << entry
112
+ end
95
113
  end
96
114
 
97
115
  dirs.sort! { |(a,_),(b)| a <=> b }.map! { |(_,ent)| ent }
@@ -117,7 +135,7 @@ class Autoindex
117
135
  dir.close if dir
118
136
  end
119
137
 
120
- def r(code, msg = nil, env = nil)
138
+ def r(code, exc = nil, env = nil)
121
139
  if env && exc && logger = env["rack.logger"]
122
140
  msg = exc.message
123
141
  msg = msg.dump if /[[:cntrl:]]/ =~ msg # prevent code injection
data/lib/yahns/daemon.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: binary -*-
2
- # Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors
2
+ # Copyright (C) 2013-2014, all contributors
3
3
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
4
- require 'yahns'
4
+ require_relative '../yahns'
5
5
 
6
6
  module Yahns::Daemon # :nodoc:
7
7
  # We don't do a lot of standard daemonization stuff:
@@ -224,9 +224,10 @@ class Yahns::HttpClient < Kgio::Socket # :nodoc:
224
224
  http_response_write(status, headers, body)
225
225
  end
226
226
 
227
+ # this is the env["rack.hijack"] callback exposed to the Rack app
227
228
  def hijack_proc(env)
228
229
  proc do
229
- self.class.queue.queue_del(self) # EPOLL_CTL_DEL
230
+ hijack_cleanup
230
231
  env[RACK_HIJACK_IO] = self
231
232
  end
232
233
  end
@@ -253,12 +254,19 @@ class Yahns::HttpClient < Kgio::Socket # :nodoc:
253
254
  end while true
254
255
  end
255
256
 
256
- def response_hijacked(fn)
257
+ # allow releasing some memory if rack.hijack is used
258
+ def hijack_cleanup
257
259
  # we must issue EPOLL_CTL_DEL before hijacking (if we issue it at all),
258
260
  # because the hijacker may close use before we get back to the epoll worker
259
261
  # loop. EPOLL_CTL_DEL saves about 200 bytes of unswappable kernel memory,
260
262
  # so it can matter if we have lots of hijacked sockets.
261
- self.class.queue.queue_del(self)
263
+ self.class.queue.queue_del(self) # EPOLL_CTL_DEL
264
+ @input = @input.close if @input
265
+ @hs = nil # no need for the HTTP parser anymore
266
+ end
267
+
268
+ def response_hijacked(fn)
269
+ hijack_cleanup
262
270
  fn.call(self)
263
271
  :ignore
264
272
  end
@@ -49,11 +49,11 @@ module Yahns::HttpContext # :nodoc:
49
49
  # input_buffering == false is handled in http_client
50
50
  return app if @client_max_body_size == nil
51
51
 
52
- require 'yahns/cap_input'
52
+ require_relative 'cap_input'
53
53
  return app if @input_buffering == true
54
54
 
55
55
  # @input_buffering == false/:lazy
56
- require 'yahns/max_body'
56
+ require_relative 'max_body'
57
57
  Yahns::MaxBody.new(app, @client_max_body_size)
58
58
  end
59
59
 
@@ -143,7 +143,7 @@ module Yahns::HttpResponse # :nodoc:
143
143
  buf = "#{response_start}#{status}\r\nDate: #{httpdate}\r\n"
144
144
  headers.each do |key, value|
145
145
  case key
146
- when %r{\ADate\z}
146
+ when %r{\ADate\z}i
147
147
  next
148
148
  when %r{\AContent-Range\z}i
149
149
  if %r{\Abytes (\d+)-(\d+)/\d+\z} =~ value
data/lib/yahns/queue.rb CHANGED
@@ -1,7 +1,7 @@
1
- # Copyright (C) 2013, Eric Wong <normalperson@yhbt.net>
1
+ # Copyright (C) 2013-2014, all contributors
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  if SleepyPenguin.const_defined?(:Epoll)
4
4
  require_relative 'queue_epoll'
5
5
  else
6
- require_relative 'queue_kqueue' # TODO
6
+ require_relative 'queue_kqueue'
7
7
  end
@@ -1,6 +1,6 @@
1
- # Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors
1
+ # Copyright (C) 2013-2014, all contributors
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
- require 'yahns'
3
+ require_relative '../yahns'
4
4
 
5
5
  module Yahns::RackupHandler # :nodoc:
6
6
  def self.default_host
data/lib/yahns/server.rb CHANGED
@@ -57,7 +57,7 @@ class Yahns::Server # :nodoc:
57
57
  bind_new_listeners!
58
58
  self.pid = @config.value(:pid) # write pid file
59
59
  if @worker_processes
60
- require 'yahns/server_mp'
60
+ require_relative 'server_mp'
61
61
  extend Yahns::ServerMP
62
62
  else
63
63
  switch_user(*@user) if @user
@@ -50,7 +50,7 @@ class Yahns::StreamInput # :nodoc:
50
50
  rv << @rbuf
51
51
  to_read -= @rbuf.size
52
52
  end
53
- @rbuf.replace('')
53
+ @rbuf.clear
54
54
  end
55
55
  rv = nil if rv.empty? && length != 0
56
56
  else
@@ -137,7 +137,7 @@ class Yahns::StreamInput # :nodoc:
137
137
  dst << @rbuf
138
138
  end
139
139
  ensure
140
- @rbuf.replace('')
140
+ @rbuf.clear
141
141
  end
142
142
 
143
143
  def eof!
@@ -44,8 +44,12 @@ class TestExtrasAutoindex < Testcase
44
44
 
45
45
  res = http.request(Net::HTTP::Get.new("/"))
46
46
  assert_equal 200, res.code.to_i
47
+ refute_match %r{\.\./}, res.body, "top level should not link to parent"
47
48
  assert_match %r{foo}, res.body
48
- assert_match %r{bar/}, res.body
49
+
50
+ res = http.request(Net::HTTP::Get.new("/bar/"))
51
+ assert_equal 200, res.code.to_i
52
+ assert_match %r{\.\./}, res.body, "link to parent present"
49
53
  end
50
54
  ensure
51
55
  quit_wait pid
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yahns
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - yahns hackers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-16 00:00:00.000000000 Z
11
+ date: 2014-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kgio
@@ -225,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
225
  version: '0'
226
226
  requirements: []
227
227
  rubyforge_project:
228
- rubygems_version: 2.2.2
228
+ rubygems_version: 2.4.3
229
229
  signing_key:
230
230
  specification_version: 4
231
231
  summary: sleepy, multi-threaded, non-blocking application server