12

I'm interested in setting my own user agent when using the ruby RestClient gem.

http://github.com/archiloque/rest-client

However, I can't find any documentation on how to do so. Any pointers?

Clay Bridges
  • 11,602
  • 10
  • 68
  • 118
Han
  • 5,374
  • 5
  • 31
  • 31

2 Answers2

20
RestClient.get 'http://localhost', :user_agent => "myagent"

See https://github.com/rest-client/rest-client/blob/master/lib/restclient.rb

Clay Bridges
  • 11,602
  • 10
  • 68
  • 118
systemfreund
  • 531
  • 5
  • 12
0

Not sure the accepted answer is very clear. User agent is set just by a header of the request. And what I see in sources is that they set default user agent by setting :user_agent header to the request. It depends on the way you use the API how you set it. See #default_headers method in the linked source file.

akostadinov
  • 17,364
  • 6
  • 77
  • 85