Skip to content

Commit

Permalink
Fix link crawler not specifying accepted content-type (#12646)
Browse files Browse the repository at this point in the history
The link crawler expects HTML documents, so set the `Accept`
header accordingly.

Fixes #12618
  • Loading branch information
ClearlyClaire authored and Gargron committed Dec 18, 2019
1 parent 68070e8 commit b364175
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/services/fetch_link_card_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def process_url
def html
return @html if defined?(@html)

Request.new(:get, @url).perform do |res|
Request.new(:get, @url).add_headers('Accept' => 'text/html').perform do |res|
if res.code == 200 && res.mime_type == 'text/html'
@html = res.body_with_limit
@html_charset = res.charset
Expand Down
2 changes: 1 addition & 1 deletion app/services/fetch_oembed_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def validate(oembed)
def html
return @html if defined?(@html)

@html = @options[:html] || Request.new(:get, @url).perform do |res|
@html = @options[:html] || Request.new(:get, @url).add_headers('Accept' => 'text/html').perform do |res|
res.code != 200 || res.mime_type != 'text/html' ? nil : res.body_with_limit
end
end
Expand Down

0 comments on commit b364175

Please sign in to comment.