v2.1.0
-
added ability to perform custom
Net::HTTP
requestshttp = HTTPWrapper.new uri = URI 'http://example.com' # Ruby v2.0.0 request = Net::HTTP::Head.new uri # Ruby v1.9.3 request = Net::HTTP::Head.new uri.request_uri http.execute request, uri
-
added ability to upload files with
multipart/form-data
content typehttp = HTTPWrapper.new params = { multipart: [ # ['file input field name', 'File instance or string', {filename: 'itsfile.jpg', content_type: '...'}] # last element is optional ['user_pic', File.open('user_pic.jpg')], ['user_photo', File.read('user_photo.jpg'), {filename: 'photo.jpg'}], # you can also specify other parameters ['user_name', 'john griffin'] ], # or you can specify other parameters in body section # it will be merged with multipart data body: { user_age: 25 } } response = http.post some_url, params
-
fixed incorrect content type for
DELETE
request -
default content type changed to
text/html
-
added
:user_agent
and:content_type
shortcuts# you can specify now user agent like so: http = HTTWrapper.new user_agent: 'custom user agent' # - or - http.user_agent = 'custom user agent' http.get sample_url # - or - http.get sample_url, user_agent: 'custom user agent'
# you can specify now content type like so: http.get sample_url, content_type: 'text/html'
-
added ability to specify headers as symbols
http.get some_url, headers: {x_requested_with: 'XMLHttpRequest'} # - the same as - http.get some_url, headers: {'X-Requested-With' => 'XMLHttpRequest'}
-
added ability to fix urls without scheme with default http scheme
http.get 'example.com' # will correctly request http://example.com
-
added
:max_redirects
option to specify redirect following limits -
added
:logger
optionlog = Logger.new http = HTTPWrapper.new logger: log - or - http.logger = $stdout
-
massive refactoring
-
:ca_file
option removed -
:validate_ssl_cert
option renamed to:verify_cert
-
soap
methods removed due to rare usage -
:method
key removed from params -
:params
key changed to:query
http.get some_url, query: { user_id: 1, text: 'abcdefg' }
-
fixed bug with timeout - it should be set in seconds, not microseconds