Method: HTTP::Message#escape

Defined in:
lib/httpclient/http.rb,
lib/httpclient/http.rb

#escape(str) ⇒ Object

:nodoc:



896
897
898
899
900
# File 'lib/httpclient/http.rb', line 896

def escape(str) # :nodoc:
  str.dup.force_encoding(Encoding::ASCII_8BIT).gsub(/([^ a-zA-Z0-9_.-]+)/) {
    '%' + $1.unpack('H2' * $1.bytesize).join('%').upcase
  }.tr(' ', '+')
end