Send user agent in open graph fetch so we don't block our own requests (#19462)
* Send user agent in open graph fetch * Update app/services/open_graph.rb Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Change user agent and test --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
f85db74b92
commit
27d6fbb285
2 changed files with 3 additions and 3 deletions
|
|
@ -85,7 +85,8 @@ class OpenGraph
|
|||
|
||||
def fetch_html(url)
|
||||
Rails.cache.fetch("#{url}_open_graph_html", expires_in: CACHE_EXPIRY_IN_MINUTES.minutes) do
|
||||
Net::HTTP.get(URI(url))
|
||||
response = HTTParty.get(url, headers: { "User-Agent" => "#{Settings::Community.community_name} (#{URL.url})" })
|
||||
response&.body
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -22,8 +22,7 @@ RSpec.describe UnifiedEmbed::Tag, type: :liquid_tag do
|
|||
headers: {
|
||||
"Accept" => "*/*",
|
||||
"Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
|
||||
"Host" => "guides.rubyonrails.org",
|
||||
"User-Agent" => "Ruby"
|
||||
"User-Agent" => "DEV(local) (http://localhost:3000)"
|
||||
},
|
||||
)
|
||||
.to_return(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue