From 38ee7f30f332890bb5e86afd4d8d1c6eca3ac199 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 28 Apr 2013 23:21:05 +0200 Subject: [PATCH] Fixed http basic authentication for post requests. --- lib/import/otrs.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/import/otrs.rb b/lib/import/otrs.rb index 898a89a0d..9dcba7682 100644 --- a/lib/import/otrs.rb +++ b/lib/import/otrs.rb @@ -49,16 +49,17 @@ module Import::OTRS http.verify_mode = OpenSSL::SSL::VERIFY_NONE end request = Net::HTTP::Post.new(uri.request_uri) - request.set_form_data(data) - response = http.request(request) # http basic auth (if needed) user = Setting.get('import_otrs_user'); password = Setting.get('import_otrs_password'); if user && user != '' && password && password != '' - response.basic_auth user, password + request.basic_auth user, password end + request.set_form_data(data) + response = http.request(request) + if !response raise "Can't connect to #{url}, got no response!" end