   if jiraIgnoreUsers == undefined
     jiraIgnoreUsers = "jira|github"
 
-  request = http.get {host: jiraDomain, port: jiraPort, auth: auth, path: "/rest/api/2/project"}, (res) ->
-    data = ''
-    res.on 'data', (chunk) ->
-      data += chunk.toString()
-    res.on 'end', () ->
-      json = JSON.parse(data)
+  robot.http(jiraUrl + "/rest/api/2/project")
+    .auth(auth)
+    .get() (err, res, body) ->
+      json = JSON.parse(body)
       jiraPrefixes = ( entry.key for entry in json )
       reducedPrefixes = jiraPrefixes.reduce (x,y) -> x + "-|" + y
       jiraPattern = "/\\b(" + reducedPrefixes + "-)(\\d+)\\b/g"


module.exports = (robot) ->
  cache = []
  jiraDomain = process.env.HUBOT_JIRA_DOMAIN
  jiraProtocol = process.env.HUBOT_JIRA_PROTOCOL || "https"
  jiraPort = process.env.HUBOT_JIRA_PORT || 80
  jiraUrl = "#{jiraProtocol}://#{jiraDomain}:#{jiraPort}"

  if jiraProtocol == 'https'
    http = require 'https'
  else
    http = require 'http'

  jiraUsername = process.env.HUBOT_JIRA_USERNAME
  jiraPassword = process.env.HUBOT_JIRA_PASSWORD
  if jiraUsername != undefined && jiraUsername.length > 0
    auth = "#{jiraUsername}:#{jiraPassword}"


#   None
#
# Configuration:
#   HUBOT_JIRA_URL (format: "https://jira-domain.com:9090")
#   HUBOT_JIRA_IGNORECASE (optional; default is "true")
#   HUBOT_JIRA_USERNAME (optional)
#   HUBOT_JIRA_PASSWORD (optional)
