Browse Source

Fix link crawler not specifying accepted content-type (#12646)

The link crawler expects HTML documents, so set the `Accept`
header accordingly.

Fixes #12618
closed-social-v3
ThibG 4 years ago
committed by Eugen Rochko
parent
commit
b364175e1b
2 changed files with 2 additions and 2 deletions
  1. +1
    -1
      app/services/fetch_link_card_service.rb
  2. +1
    -1
      app/services/fetch_oembed_service.rb

+ 1
- 1
app/services/fetch_link_card_service.rb View File

@ -45,7 +45,7 @@ class FetchLinkCardService < BaseService
def html def html
return @html if defined?(@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' if res.code == 200 && res.mime_type == 'text/html'
@html = res.body_with_limit @html = res.body_with_limit
@html_charset = res.charset @html_charset = res.charset

+ 1
- 1
app/services/fetch_oembed_service.rb View File

@ -93,7 +93,7 @@ class FetchOEmbedService
def html def html
return @html if defined?(@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 res.code != 200 || res.mime_type != 'text/html' ? nil : res.body_with_limit
end end
end end

Loading…
Cancel
Save