Module: Puma::Util
- Defined in:
- lib/puma/util.rb
Defined Under Namespace
Classes: HeaderHash
Constant Summary collapse
- DEFAULT_SEP =
/[&;] */n
Class Method Summary collapse
- .escape(s, encoding = nil) ⇒ Object
- .nakayoshi_gc(events) ⇒ Object
-
.parse_query(qs, d = nil, &unescaper) ⇒ Object
Stolen from Mongrel, with some small modifications: Parses a query string by breaking it up at the '&' and ';' characters.
- .pipe ⇒ Object
-
.purge_interrupt_queue ⇒ Object
An instance method on Thread has been provided to address bugs.ruby-lang.org/issues/13632, which currently effects some older versions of Ruby: 2.2.7 2.2.8 2.2.9 2.2.10 2.3.4 2.4.1 Additional context: github.com/puma/puma/pull/1345.
- .unescape(s, encoding = nil) ⇒ Object
Class Method Details
.escape(s, encoding = nil) ⇒ Object
24 25 26 |
# File 'lib/puma/util.rb', line 24 def escape(s, encoding = Encoding::UTF_8) URI.encode_www_form_component(s, encoding) end |
.nakayoshi_gc(events) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/puma/util.rb', line 43 def nakayoshi_gc(events) events.log "! Promoting existing objects to old generation..." 4.times { GC.start(full_mark: false) } if GC.respond_to?(:compact) events.log "! Compacting..." GC.compact end events.log "! Friendly fork preparation complete." end |
.parse_query(qs, d = nil, &unescaper) ⇒ Object
Stolen from Mongrel, with some small modifications: Parses a query string by breaking it up at the '&' and ';' characters. You can also use this to parse cookies by changing the characters used in the second parameter (which defaults to '&;').
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/puma/util.rb', line 60 def parse_query(qs, d = nil, &unescaper) unescaper ||= method(:unescape) params = {} (qs || '').split(d ? /[#{d}] */n : DEFAULT_SEP).each do |p| next if p.empty? k, v = p.split('=', 2).map(&unescaper) if cur = params[k] if cur.class == Array params[k] << v else params[k] = [cur, v] end else params[k] = v end end params end |
.pipe ⇒ Object
9 10 11 |
# File 'lib/puma/util.rb', line 9 def pipe IO.pipe end |
.purge_interrupt_queue ⇒ Object
An instance method on Thread has been provided to address bugs.ruby-lang.org/issues/13632, which currently effects some older versions of Ruby: 2.2.7 2.2.8 2.2.9 2.2.10 2.3.4 2.4.1 Additional context: github.com/puma/puma/pull/1345
16 17 18 |
# File 'lib/puma/util.rb', line 16 def purge_interrupt_queue Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue end |
.unescape(s, encoding = nil) ⇒ Object
28 29 30 |
# File 'lib/puma/util.rb', line 28 def unescape(s, encoding = Encoding::UTF_8) URI.decode_www_form_component(s, encoding) end |