HttpClient
version: only json;
Installation
Add this line to your application's Gemfile:
gem 'l6_http'
And then execute:
$ bundle
Or install it yourself as:
$ gem install l6_http
Usage
http
res = Http.new(url_base).get("method",params)
https
res = Https.new(url_base).get("method") res = Https.new(url_base).post("method",params,body) res = Https.new(url_base).post_without_params("method",body) header = "Content-Type":"application/json","cache-control":"no-cache" body = href="mailto:[email protected]">[email protected]","password":"pass121" res = Https.new(url_base).post_without_params("method",body,header)
About Response
https://docs.ruby-lang.org/en/2.0.0/Net/HTTP.html
Headers
res['Set-Cookie'] # => String res.get_fields('set-cookie') # => Array res.to_hash['set-cookie'] # => Array puts "Headers: #resres.to_hashres.to_hash.inspect"
Status
puts res.code # => '200' puts res.message # => 'OK' puts res.class.name # => 'HTTPOK'
Body
puts res.body if res.response_body_permitted? render json: response.read_body if response.code == 200
Development
Contributing
Bug reports and pull requests are welcome on GitHub at https://gitlab.com/vini.freire.oliveira/http_client. This project is intended to be a safe,welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the HttpClient project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.