I'm working with the UnderArmour API and requesting the gpx files for routes of a given location, and it's working fine. However, the download takes a while, and I'd like to download a compressed file per their compression page:
All endpoints support response compression. To enable compression, your request must provide an “Accept-Encoding” with the value set to gzip.
GET /7.1/... HTTP/1.1
Host: api.underarmour.com
Accept: application/json
Accept-Encoding: gzip
The code that I'm using to try this is here (I've replaced my user token with XXX for privacy):
gpxurl <- "https://api.ua.com/v7.1/route/?close_to_location=51.5%2C-0.1&format=gpx&field_set=detailed&limit=40"
r <- GET(gpxurl, add_headers("authorization"=XXX,
"Accept"="application/json",
"Accept-Encoding"="gzip"))
The file I'm getting doesn't seem to be compressed. It takes just as long to download as the original file, and I don't have to do any extraction. I can't seem to check the headers that httpbin received because the file returned is in raw form and str(content(r)$headers) fails because the format is simply an atomic vector of bytes sent back from the server. The headers that it sent back are below, which don't include the "Accept" or "Accept-Encoding" headers that I'd expect to be there if it worked correctly.
str(headers(r))
List of 11
$ content-type : chr "application/gpx+xml; charset=UTF-8"
$ content-length : chr "3506843"
$ connection : chr "keep-alive"
$ access-control-allow-origin: chr "*"
$ date : chr "Wed, 28 Feb 2018 17:29:37 GMT"
$ p3p : chr "CP=\"NOI DSP COR CURa ADMa DEVa TAIa OUR BUS IND UNI COM NAV INT\""
$ server : chr "edge-proxy/1.0"
$ uacf-request-id : chr "9c573cc7-3589-4987-a297-303722b6e6e9"
$ x-cache : chr "Miss from cloudfront"
$ via : chr "1.1 7db492e48a5d55351dcb787a8a14e113.cloudfront.net (CloudFront)"
$ x-amz-cf-id : chr "c7zlkuaUXoYVIsmpZvQlHHpGDNobFJw49nzhlg0_gXuGcbWBS6_zCQ=="
- attr(*, "class")= chr [1:2] "insensitive" "list"
How can I obtain a compressed GPX file from the UnderArmour API?