Guest User

Untitled

a guest
Dec 26th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. require 'net/http'
  2.  
  3. uri = URI('http://www.example.com/search.cgi')
  4. res = Net::HTTP.post_form(uri, 'q' => ['ruby', 'perl'], 'max' => '50')
  5. puts res.body
  6.  
  7. gem "http"
  8.  
  9. require 'http'
  10. response = HTTP.post("https://api.test/post", :params => {:id => 5})
  11. response.body # retorna um objeto representando a resposta
  12. response.code # retorna o código HTTP da resposta, e.g. 404, 500, 200
  13.  
  14. HTTP.basic_auth(:user => "user", :pass => "pass")
  15. .get("https://example.com")
  16.  
  17. HTTP.auth("Bearer VGhlIEhUVFAgR2VtLCBST0NLUw")
  18. .get("https://example.com")
Add Comment
Please, Sign In to add comment