File: headers_and_user_agents.rb

package info (click to toggle)
ruby-httparty 0.13.7-1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 736 kB
  • sloc: ruby: 4,741; xml: 425; sh: 35; makefile: 11
file content (6 lines) | stat: -rw-r--r-- 317 bytes parent folder | download
1
2
3
4
5
6
# To send custom user agents to identify your application to a web service (or mask as a specific browser for testing), send "User-Agent" as a hash to headers as shown below.

require 'httparty'

APPLICATION_NAME = "Httparty"
response = HTTParty.get('http://example.com', headers: {"User-Agent" => APPLICATION_NAME})