httr / RPresto - problem reading HTTP headers in response to POST

Hi all, wondering whether anyone has seen this issue with RPresto (which relies on httr). I had not experienced this until today, possibly after I reinstalled my environment last Friday.

After I send a query to my Presto server, like this, I get an error to do with the content-type HTTP header:

connection_to_presto <- RPresto::dbConnect(
  RPresto::Presto(),
  host = "host_name",
  port = 8888,
  catalog = "catalog_name",
  schema = "schema_name"
)
   
dbListTables(connection_to_presto)
#> Error in x$headers[["Content-Type"]] : subscript out of bounds

I've traced this back to the content() function in the httr package; this code returns the same error:

post.response <- httr::POST(
  url = "host:8888/v1/statement",
  body = enc2utf8("show tables"),
  config = httr::add_headers(
    "X-Presto-User" = "my_name",
    "X-Presto-Catalog" = "catalog_name",
    "X-Presto-Schema" = "schema_name",
    "X-Presto-Time-Zone" = "UTC",
    "User-Agent" = "me messing around"
  )
)

httr::content(post.response)
#> Error in x$headers[["Content-Type"]] : subscript out of bounds

When I check the headers in the output of POST (with httr::parse_http_headers(post.response$headers)) I see that there is a header in my response called 'content-type' (as opposed to 'Content-Type') which makes me think that this could be to do with lower case vs upper case. From quickly looking at the source of httr it looks like httr is supposed to deal with HTTP headers in a case-insensitive way so not completely sure about this.

I get this error with R 3.6.0 and 3.6.1, the most recent version of RPresto (1.3.3, which hasn't changed recently) and both the Github latest version of httr as well as httr v1.4.1 and v1.4.0 from CRAN.

Thanks in advance if anyone has seen anything similar!

Problem was solved by adding 'http://' to the beginning of the host name; for some reason httr doesn't parse headers from raw binary into a list if the protocol isn't specified, which causes the error.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.