diff options
author | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-06-03 15:36:59 +0200 |
---|---|---|
committer | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-06-03 15:36:59 +0200 |
commit | a0b58495bf3916bd371257b00a1589e556ffb7c3 (patch) | |
tree | 1db54f799d0d354b51445416ddeb18ff10afa8df | |
parent | Assign registry and bot instances when initializating the BugzillaInstance ob... (diff) | |
download | rbot-bugzilla-a0b58495bf3916bd371257b00a1589e556ffb7c3.tar.gz rbot-bugzilla-a0b58495bf3916bd371257b00a1589e556ffb7c3.tar.bz2 rbot-bugzilla-a0b58495bf3916bd371257b00a1589e556ffb7c3.zip |
Use the httputil functions from rbot for fetching the data.
Instead of using httpclient extension, use the httputil methods from
rbot itself to fetch the data.
This way we'll apply the options as they are set in the configuration
file, without having to deal with them directly.
Unfortunately for now httputil does not support permanent connections,
so it will likely be slower. On the other hand, httputil supports
local caching, which should make further access of a single bug
faster.
A slower access is still preferred to an almost infinite connection
leak.
-rw-r--r-- | bugzilla.rb | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/bugzilla.rb b/bugzilla.rb index 59ddff3..754f113 100644 --- a/bugzilla.rb +++ b/bugzilla.rb @@ -18,8 +18,6 @@ require 'set' require 'rexml/document' require 'csv' -require 'httpclient' - # Try loading htmlentities for entity expansion, but don't fail even # if it's not available. begin @@ -71,7 +69,7 @@ class BugzillaPlugin < Plugin # Exception class for an error loading the bug data. # It is thrown when REXML can't create a new document from the data - # returned by HTTP client + # returned by the HTTP connection class EErrorLoading < Exception def message "Unable to load bug ##{@bugno} from #{@zilla}" @@ -238,7 +236,7 @@ class BugzillaPlugin < Plugin # First off let's see if xml.cgi is present begin test_dataurl = "#{baseurl}/xml.cgi?id=@BUGNO@" - test_bugdata = REXML::Document.new(client.get_content(test_dataurl.gsub("@BUGNO@", "50"))) + test_bugdata = REXML::Document.new(@bot.httputil.get(test_dataurl.gsub("@BUGNO@", "50"))) if test_bugdata.root.name == "bugzilla" @dataurl = test_dataurl return @@ -250,7 +248,7 @@ class BugzillaPlugin < Plugin # If not fall back to asking for the XML data to show_bug.cgi begin test_dataurl = "#{showbugurl}&ctype=xml" - test_bugdata = REXML::Document.new(client.get_content(test_dataurl.gsub("@BUGNO@", "50"))) + test_bugdata = REXML::Document.new(@bot.httputil.get(test_dataurl.gsub("@BUGNO@", "50"))) if test_bugdata.root.name == "bugzilla" @dataurl = test_dataurl return @@ -267,23 +265,6 @@ class BugzillaPlugin < Plugin @reporturl = "#{baseurl}/report.cgi?action=wrap&ctype=csv&format=table" end - # Provide an HTTP client connected to the current Bugzilla instance. - # - # If a client is already open it is returned, otherwise a new one - # is opened. - # - # SSL support is always set not to verify the validity of the - # certificate, as a lot of Bugzilla instances used for Free - # Software development don't have proper SSL certificates, but - # just self-signed certificates. - def client - return @client if @client - - @client = HTTPClient.new(nil, useragent) - - return @client - end - # Deletes the client object if any def delete_client # TODO: httpclient does not seem to provide a way to close the @@ -298,7 +279,7 @@ class BugzillaPlugin < Plugin def summary(bugno) raise EInvalidInstance.new(self.name, "No XML data URL available") if dataurl == nil - bugdata = REXML::Document.new(client.get_content(dataurl.gsub("@BUGNO@", bugno))) + bugdata = REXML::Document.new(@bot.httputil.get(dataurl.gsub("@BUGNO@", bugno))) raise EErrorLoading.new(name, bugno) unless bugdata @@ -356,7 +337,7 @@ class BugzillaPlugin < Plugin buglist_url += "&field0-0-0=bug_id&remaction=&type0-0-0=greaterthan&value0-0-0=#{lastseenid}" end - buglist = CSV::Reader.create(client.get_content(buglist_url)).to_a + buglist = CSV::Reader.create(@bot.httputil.get(buglist_url)).to_a buglist.delete_at(0) upper_bound = [buglist.size, 5].min buglist[-upper_bound..-1].each do |bug| @@ -372,7 +353,7 @@ class BugzillaPlugin < Plugin def report(params) url = "#{reporturl}&#{params}" - reportdata = CSV::Reader.create(client.get_content(url)).to_a + reportdata = CSV::Reader.create(@bot.httputil.get(url)).to_a return reportdata end |