Send a User-Agent to Overpass, overpass-api.de 406s Ruby's default
The Camper POIs plugin died with "plugin exited with status 1": Net::HTTP's bare "Ruby" User-Agent now gets a 406 Not Acceptable from overpass-api.de, any identifying one goes through.
This commit is contained in:
1 parent
ede21454a2
commit
33be95ef59
1 file changed
+5
-1
@@ -54,7 +54,11 @@ module Maptool
|
|||||||
def self.fetch(bbox, timeout: 60)
|
def self.fetch(bbox, timeout: 60)
|
||||||
query = build_query(bbox, timeout: timeout)
|
query = build_query(bbox, timeout: timeout)
|
||||||
uri = URI(OVERPASS_API)
|
uri = URI(OVERPASS_API)
|
||||||
response = Net::HTTP.post_form(uri, "data" => query)
|
# overpass-api.de answers Net::HTTP's default "Ruby" User-Agent with
|
||||||
|
# a 406 (verified 2026-10-09) — any identifying UA gets through.
|
||||||
|
request = Net::HTTP::Post.new(uri, "User-Agent" => "maptool (Overpass camper POIs plugin)")
|
||||||
|
request.set_form_data("data" => query)
|
||||||
|
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(request) }
|
||||||
raise FetchError, "unexpected response #{response.code}" unless response.is_a?(Net::HTTPSuccess)
|
raise FetchError, "unexpected response #{response.code}" unless response.is_a?(Net::HTTPSuccess)
|
||||||
|
|
||||||
JSON.parse(response.body)
|
JSON.parse(response.body)
|
||||||
|
|||||||
Reference in new issue
Block a user