Skip to content

Commit 2cc9a55

Browse files
authored
Set user agent for api.rubyonrails.org (#343)
1 parent fbb9176 commit 2cc9a55

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/ruby_lsp/ruby_lsp_rails/support/rails_document_client.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ def generate_rails_document_urls(name)
6868

6969
$stderr.puts("Fetching search index for Rails documentation")
7070

71-
response = Net::HTTP.get_response(URI("#{RAILS_DOC_HOST}/v#{RAILTIES_VERSION}/js/search_index.js"))
71+
response = Net::HTTP.get_response(
72+
URI("#{RAILS_DOC_HOST}/v#{RAILTIES_VERSION}/js/search_index.js"),
73+
{ "User-Agent" => "ruby-lsp-rails/#{RubyLsp::Rails::VERSION}" },
74+
)
7275

7376
body = case response
7477
when Net::HTTPSuccess

test/ruby_lsp_rails/hover_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class HoverTest < ActiveSupport::TestCase
1212
.with(
1313
headers: {
1414
"Host" => "api.rubyonrails.org",
15-
"User-Agent" => "Ruby",
15+
"User-Agent" => %r{^ruby-lsp-rails\/.*$},
1616
},
1717
)
1818
.to_return(status: 200, body: body, headers: {})

0 commit comments

Comments
 (0)