Skip to content

Commit

Permalink
Use ruby Net::HTTP in place of unmaintained httpclient
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Dec 4, 2024
1 parent 6985b0a commit f43c340
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
13 changes: 3 additions & 10 deletions cookbooks/wordpress/libraries/wordpress.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
require "chef/mixin/shell_out"

require "addressable"
require "httpclient"
require "json"
require "net/http"

class Chef
module Wordpress
extend Chef::Mixin::ShellOut

@api_responses = {}

class << self
Expand All @@ -22,17 +17,15 @@ def current_plugin_version(name)
private

def core_version_check
api_get("https://api.wordpress.org/core/version-check/1.7")
api_get("https://api.wordpress.org/core/version-check/1.7/")
end

def plugin_information(name)
api_get("https://api.wordpress.org/plugins/info/1.2/?action=plugin_information&request[slug]=#{name}")
end

def api_get(url)
http_client = ::HTTPClient.new
http_client.ssl_config.set_default_paths # https://github.com/nahi/httpclient/issues/445
@api_responses[url] ||= ::JSON.parse(http_client.get_content(url))
@api_responses[url] ||= ::JSON.parse(Net::HTTP.get(URI(url)))
end
end
end
Expand Down
1 change: 0 additions & 1 deletion cookbooks/wordpress/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@
depends "mysql"
depends "php"
depends "ssl"
gem "httpclient"

0 comments on commit f43c340

Please sign in to comment.