From ced782ecb21c629e13306010ca34bbaa8e3bb473 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 15 Jan 2011 14:48:33 +0000 Subject: [PATCH] Adds a User-Agent header to Redmine mailhandler requests (#7318). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4725 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- extra/mail_handler/rdm-mailhandler.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/extra/mail_handler/rdm-mailhandler.rb b/extra/mail_handler/rdm-mailhandler.rb index fe9460a6b..c1b5c287d 100644 --- a/extra/mail_handler/rdm-mailhandler.rb +++ b/extra/mail_handler/rdm-mailhandler.rb @@ -57,10 +57,11 @@ require 'rdoc/usage' module Net class HTTPS < HTTP - def self.post_form(url, params) + def self.post_form(url, params, headers) request = Post.new(url.path) request.form_data = params request.basic_auth url.user, url.password if url.user + request.initialize_http_header(headers) http = new(url.host, url.port) http.use_ssl = (url.scheme == 'https') http.start {|h| h.request(request) } @@ -121,6 +122,8 @@ class RedmineMailHandler def submit(email) uri = url.gsub(%r{/*$}, '') + '/mail_handler' + headers = { 'User-Agent' => "Redmine mail handler/#{VERSION}" } + data = { 'key' => key, 'email' => email, 'allow_override' => allow_override, 'unknown_user' => unknown_user, @@ -128,7 +131,7 @@ class RedmineMailHandler issue_attributes.each { |attr, value| data["issue[#{attr}]"] = value } debug "Posting to #{uri}..." - response = Net::HTTPS.post_form(URI.parse(uri), data) + response = Net::HTTPS.post_form(URI.parse(uri), data, headers) debug "Response received: #{response.code}" case response.code.to_i -- 2.39.5