From: Tom Hughes Date: Wed, 10 Jul 2024 17:29:14 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/pull/4971' X-Git-Tag: live~409 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/2f838921c0c1bb0ca2bb85d80edda83e115aaca2?hp=9a9cf59adc0cd94a65ed4c3de0190cbef06afe44 Merge remote-tracking branch 'upstream/pull/4971' --- diff --git a/Gemfile.lock b/Gemfile.lock index 774d795bc..284e97adc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -95,8 +95,8 @@ GEM autoprefixer-rails (10.4.16.0) execjs (~> 2) aws-eventstream (1.3.0) - aws-partitions (1.950.0) - aws-sdk-core (3.201.0) + aws-partitions (1.954.0) + aws-sdk-core (3.201.1) aws-eventstream (~> 1, >= 1.3.0) aws-partitions (~> 1, >= 1.651.0) aws-sigv4 (~> 1.8) @@ -186,7 +186,7 @@ GEM doorkeeper (>= 5.5, < 5.8) jwt (>= 2.5) drb (2.2.1) - dry-configurable (1.1.0) + dry-configurable (1.2.0) dry-core (~> 1.0, < 2) zeitwerk (~> 2.6) dry-core (1.0.1) @@ -234,8 +234,9 @@ GEM factory_bot_rails (6.4.3) factory_bot (~> 6.4) railties (>= 5.0.0) - faraday (2.9.2) + faraday (2.10.0) faraday-net_http (>= 2.0, < 3.2) + logger faraday-net_http (3.1.0) net-http ffi (1.17.0) @@ -288,7 +289,7 @@ GEM image_size (3.4.0) in_threads (1.6.0) io-console (0.7.2) - irb (1.13.2) + irb (1.14.0) rdoc (>= 4.0.0) reline (>= 0.4.2) jbuilder (2.12.0) @@ -326,7 +327,7 @@ GEM marcel (1.0.4) matrix (0.4.2) maxminddb (0.1.22) - mini_magick (4.13.1) + mini_magick (4.13.2) mini_mime (1.1.5) mini_portile2 (2.8.7) mini_racer (0.9.0) @@ -402,7 +403,7 @@ GEM omniauth (~> 2.0) openstreetmap-deadlock_retry (1.3.1) parallel (1.25.1) - parser (3.3.3.0) + parser (3.3.4.0) ast (~> 2.4.1) racc pg (1.5.6) @@ -490,13 +491,13 @@ GEM rouge (4.3.0) rtlcss (0.2.1) mini_racer (>= 0.6.3) - rubocop (1.64.1) + rubocop (1.65.0) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) + regexp_parser (>= 2.4, < 3.0) rexml (>= 3.2.5, < 4.0) rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) @@ -588,7 +589,7 @@ GEM crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) webrick (1.8.1) - websocket (1.2.10) + websocket (1.2.11) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) diff --git a/lib/nominatim.rb b/lib/nominatim.rb index adb041da4..5e4a18b51 100644 --- a/lib/nominatim.rb +++ b/lib/nominatim.rb @@ -11,14 +11,16 @@ module Nominatim url = "#{Settings.nominatim_url}reverse?lat=#{lat}&lon=#{lon}&zoom=#{zoom}&accept-language=#{language}" begin - response = Timeout.timeout(4) do - REXML::Document.new(Net::HTTP.get(URI.parse(url))) + response = OSM.http_client.get(URI.parse(url)) do |request| + request.options.timeout = 4 end + + results = REXML::Document.new(response.body) if response.success? rescue StandardError - response = nil + results = nil end - if response && result = response.get_text("reversegeocode/result") + if results && result = results.get_text("reversegeocode/result") result.value else "#{number_with_precision(lat, :precision => 3)}, #{number_with_precision(lon, :precision => 3)}" diff --git a/lib/osm.rb b/lib/osm.rb index dd273418e..46f37036f 100644 --- a/lib/osm.rb +++ b/lib/osm.rb @@ -535,7 +535,8 @@ module OSM # Return the HTTP client to use def self.http_client - @http_client ||= Faraday.new(:request => { :timeout => 15 }) + @http_client ||= Faraday.new(:request => { :timeout => 15 }, + :headers => { :user_agent => Settings.server_url }) end # Return the MaxMindDB database handle diff --git a/yarn.lock b/yarn.lock index fe77c07e3..d13b71419 100644 --- a/yarn.lock +++ b/yarn.lock @@ -624,9 +624,9 @@ punycode@^2.1.0: integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== qs@^6.9.4: - version "6.12.2" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.12.2.tgz#5443b587f3bf73ac68968de491e5b25bafe04478" - integrity sha512-x+NLUpx9SYrcwXtX7ob1gnkSems4i/mGZX5SlYxwIau6RrUSODO89TR/XDGGpn5RPWSYIB+aSfuSlV5+CmbTBg== + version "6.12.3" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.12.3.tgz#e43ce03c8521b9c7fd7f1f13e514e5ca37727754" + integrity sha512-AWJm14H1vVaO/iNZ4/hO+HyaTehuy9nRqVdkTqlJt0HWvBiBIEXFmb4C0DGeYo3Xes9rrEW+TxHsaigCbN5ICQ== dependencies: side-channel "^1.0.6"