user-agent.diff

Patch to add user-agent support to Redmine's mailhandler - Ве Fio, 2011-01-13 12:06

Download (1.34 KB)

View differences:

extra/mail_handler/rdm-mailhandler.rb (working copy)
57 57

  
58 58
module Net
59 59
  class HTTPS < HTTP
60
    def self.post_form(url, params)
60
    def self.post_form(url, params, headers)
61 61
      request = Post.new(url.path)
62 62
      request.form_data = params
63 63
      request.basic_auth url.user, url.password if url.user
64
      request.initialize_http_header(headers)
64 65
      http = new(url.host, url.port)
65 66
      http.use_ssl = (url.scheme == 'https')
66 67
      http.start {|h| h.request(request) }
......
121 122
  def submit(email)
122 123
    uri = url.gsub(%r{/*$}, '') + '/mail_handler'
123 124
    
125
    headers = { 'User-Agent' => "Redmine Mailhandler/#{VERSION}" }
126
    
124 127
    data = { 'key' => key, 'email' => email, 
125 128
                           'allow_override' => allow_override,
126 129
                           'unknown_user' => unknown_user,
......
128 131
    issue_attributes.each { |attr, value| data["issue[#{attr}]"] = value }
129 132
             
130 133
    debug "Posting to #{uri}..."
131
    response = Net::HTTPS.post_form(URI.parse(uri), data)
134
    response = Net::HTTPS.post_form(URI.parse(uri), data, headers)
132 135
    debug "Response received: #{response.code}"
133 136
    
134 137
    case response.code.to_i