Skip to content

Commit

Permalink
#13 done
Browse files Browse the repository at this point in the history
  • Loading branch information
veny committed Oct 31, 2012
1 parent b63b322 commit 6041218
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
10 changes: 9 additions & 1 deletion lib/orientdb4r/rest/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ def initialize(options) #:nodoc:
:nodes => :optional,
:connection_library => :restclient,
:load_balancing => :sequence,
:proxy => :optional
:proxy => :optional,
:user_agent => :optional
}
verify_and_sanitize_options(options, options_pattern)

Expand Down Expand Up @@ -58,6 +59,13 @@ def initialize(options) #:nodoc:
end
end

# user-agent
agent = options[:user_agent]
unless agent.nil?
puts "CCCCCCCCC #{agent}"
nodes.each { |node| node.user_agent = agent }
end

Orientdb4r::logger.info "client initialized with #{@nodes.size} node(s) "
Orientdb4r::logger.info "connection_library=#{options[:connection_library]}, load_balancing=#{load_balancing}"
end
Expand Down
1 change: 1 addition & 0 deletions lib/orientdb4r/rest/excon_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def headers(options)
rslt = {'Authorization' => basic_auth_header(options[:user], options[:password])}
rslt['Cookie'] = "#{SESSION_COOKIE_NAME}=#{session_id}" unless session_id.nil?
rslt['Content-Type'] = options[:content_type] if options.include? :content_type
rslt['User-Agent'] = user_agent unless user_agent.nil?
rslt
end

Expand Down
2 changes: 2 additions & 0 deletions lib/orientdb4r/rest/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class RestNode < Node
SESSION_COOKIE_NAME = 'OSESSIONID'

attr_reader :ssl
# HTTP header 'User-Agent'
attr_accessor :user_agent

###
# Constructor.
Expand Down
4 changes: 3 additions & 1 deletion lib/orientdb4r/rest/restclient_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ def request(options) #:nodoc:
data = '' if data.nil? and :post == opts[:method] # POST has to have data
opts[:payload] = data unless data.nil?

# headers
# cookies
opts[:cookies] = { SESSION_COOKIE_NAME => session_id} unless session_id.nil?
# headers
opts[:headers] = { 'User-Agent' => user_agent } unless user_agent.nil?

begin
response = ::RestClient::Request.new(opts).execute
Expand Down
1 change: 1 addition & 0 deletions lib/orientdb4r/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Orientdb4r

# Version history.
VERSION_HISTORY = [
['0.3.2', '2012-11-02', "Feature #13 (User-Agent), #16 (configurable RECOVERY_TIMEOUT)"],
['0.3.1', '2012-08-27', "Timeout for reuse of dirty nodes in load balancing; BF #14, BF #15"],
['0.3.0', '2012-08-01', "Added support for cluster of distributed servers + load balancing"],
['0.2.10', '2012-07-21', "Experimental support for Excon HTTP library with Keep-Alive connection"],
Expand Down

0 comments on commit 6041218

Please sign in to comment.