Fixed http basic authentication for post requests.

This commit is contained in:
Martin Edenhofer 2013-04-28 23:21:05 +02:00
parent 83bc417933
commit 38ee7f30f3

View file

@ -49,16 +49,17 @@ module Import::OTRS
http.verify_mode = OpenSSL::SSL::VERIFY_NONE http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end end
request = Net::HTTP::Post.new(uri.request_uri) request = Net::HTTP::Post.new(uri.request_uri)
request.set_form_data(data)
response = http.request(request)
# http basic auth (if needed) # http basic auth (if needed)
user = Setting.get('import_otrs_user'); user = Setting.get('import_otrs_user');
password = Setting.get('import_otrs_password'); password = Setting.get('import_otrs_password');
if user && user != '' && password && password != '' if user && user != '' && password && password != ''
response.basic_auth user, password request.basic_auth user, password
end end
request.set_form_data(data)
response = http.request(request)
if !response if !response
raise "Can't connect to #{url}, got no response!" raise "Can't connect to #{url}, got no response!"
end end