Han
Han

Reputation: 5642

How do I set the user agent for Ruby's RestClient?

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?

Upvotes: 12

Views: 7980

Answers (2)

akostadinov
akostadinov

Reputation: 18614

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.

Upvotes: 0

systemfreund
systemfreund

Reputation: 551

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

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

Upvotes: 21

Related Questions