Skip to content

Error fetching responses from OpenStreetMap's "Nominatim" geocoding API #508

@timriley

Description

@timriley

When I make a request to OpenStreetMap's "Nominatim" geocoding API using the HTTP gem, I receive an erroneously blank response:

response = HTTP.get("https://nominatim.openstreetmap.org/search/canberra")
# => #<HTTP::Response/1.1 200 OK {"Date"=>"Mon, 05 Nov 2018 20:55:13 GMT", "Server"=>"Apache/2.4.29 (Ubuntu)", "Access-Control-Allow-Origin"=>"*", "Access-Control-Allow-Methods"=>"OPTIONS,GET", "Strict-Transport-Security"=>"max-age=31536000; includeSubDomains; preload", "Expect-Ct"=>"max-age=0, report-uri=\"https://openstreetmap.report-uri.com/r/d/ct/reportOnly\"", "Upgrade"=>"h2", "Connection"=>"Upgrade, close", "Vary"=>"Accept-Encoding", "Transfer-Encoding"=>"chunked", "Content-Type"=>"text/html; charset=UTF-8"}>

response.body.to_s
# => ""

Whereas it works fine with net/http (and many other HTTP gems, including Typhoeus)

Net::HTTP.get(URI("https://nominatim.openstreetmap.org/search/canberra"))
# => "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <title>OpenStreetMap Nominatim: Search</title> ... "

Other requests with the HTTP gem do work fine, so I can only imagine this is something to do with the response from this particular service. It seems the combination of a Transfer-Encoding: chunked header and the absence of a Content-Length header might have something to do with it? I'm at least led that way by looking through the issues history and finding #45.

However, since that issue was closed over 4 years ago, and I'm finding a similar issue with the latest (4.0.0) version of the gem, I thought I should open a new one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions