]> source.dussan.org Git - redmine.git/commitdiff
Adds a User-Agent header to Redmine mailhandler requests (#7318).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 15 Jan 2011 14:48:33 +0000 (14:48 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 15 Jan 2011 14:48:33 +0000 (14:48 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4725 e93f8b46-1217-0410-a6f0-8f06a7374b81

extra/mail_handler/rdm-mailhandler.rb

index fe9460a6b9451cf0ae9de385ac90c1c2be01a307..c1b5c287d0ddf6418bf5e119210bf1b9bc83330a 100644 (file)
@@ -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