Feature request: using an User-Agent?
maelle opened this issue · comments
Would it be possible to use an User-Agent in requests? E.g. by default it'd be this package, but in EMODnetWFS requests we'd add the package name. (Sorry if I missed something obvious!)
@maelle You can already do it by using the request headers
argument to the WFSClient
constructor.
See below code (with logger = "DEBUG", so you can see the User agent set as request header)
wfs <- ows4R::WFSClient$new(
"http://geo.vliz.be/geoserver/Dataportal/wfs",
serviceVersion = "2.0.0",
headers = c("User-Agent" = "EMODnetWFS"),
logger = "DEBUG"
)
oh, awesome, thank you and sorry!!
no problem, you're welcome
Actually I might still have a small feature request, maybe just an encoding one as the user agent can't be more than one word at the moment, see below
wfs <- ows4R::WFSClient$new(
"http://geo.vliz.be/geoserver/Emodnetbio/wfs",
serviceVersion = "2.0.0"
)
#> Loading ISO 19139 XML schemas...
#> Loading ISO 19115 codelists...
#> Loading IANA mime types...
#> No encoding supplied: defaulting to UTF-8.
wfs$getFeatures("mediseh_cymodocea_pnt")
#> Simple feature collection with 1265 features and 3 fields
#> Geometry type: POINT
#> Dimension: XY
#> Bounding box: xmin: -5.224157 ymin: 31.12298 xmax: 35.9138 ymax: 45.7739
#> Geodetic CRS: WGS 84
#> First 10 features:
#> gml_id id country the_geom
#> 1 mediseh_cymodocea_pnt.1 0 Spagna POINT (3.209945 42.03786)
#> 2 mediseh_cymodocea_pnt.2 0 Spagna POINT (3.211778 42.04653)
#> 3 mediseh_cymodocea_pnt.3 0 Spagna POINT (0.511995 40.50794)
#> 4 mediseh_cymodocea_pnt.4 0 Spagna POINT (0.522185 40.52022)
#> 5 mediseh_cymodocea_pnt.5 0 Spagna POINT (0.503069 40.49445)
#> 6 mediseh_cymodocea_pnt.6 0 Spagna POINT (0.502418 40.47931)
#> 7 mediseh_cymodocea_pnt.7 0 Spagna POINT (0.463433 40.45048)
#> 8 mediseh_cymodocea_pnt.8 0 Spagna POINT (0.449706 40.43236)
#> 9 mediseh_cymodocea_pnt.9 0 Spagna POINT (0.445039 40.41589)
#> 10 mediseh_cymodocea_pnt.10 0 Spagna POINT (0.425821 40.3975)
wfs <- ows4R::WFSClient$new(
"http://geo.vliz.be/geoserver/Emodnetbio/wfs",
serviceVersion = "2.0.0",
headers = c("User-Agent" = "EMODnetWFS R Package (https://github.com/EMODnet/EMODnetWFS)")
)
wfs$getFeatures("mediseh_cymodocea_pnt")
#> Error in xmlParse(text): empty or no content specified
wfs <- ows4R::WFSClient$new(
"http://geo.vliz.be/geoserver/Emodnetbio/wfs",
serviceVersion = "2.0.0",
headers = c("User-Agent" = "EMODnetWFS")
)
wfs$getFeatures("mediseh_cymodocea_pnt")
#> Simple feature collection with 1265 features and 3 fields
#> Geometry type: POINT
#> Dimension: XY
#> Bounding box: xmin: -5.224157 ymin: 31.12298 xmax: 35.9138 ymax: 45.7739
#> Geodetic CRS: WGS 84
#> First 10 features:
#> gml_id id country the_geom
#> 1 mediseh_cymodocea_pnt.1 0 Spagna POINT (3.209945 42.03786)
#> 2 mediseh_cymodocea_pnt.2 0 Spagna POINT (3.211778 42.04653)
#> 3 mediseh_cymodocea_pnt.3 0 Spagna POINT (0.511995 40.50794)
#> 4 mediseh_cymodocea_pnt.4 0 Spagna POINT (0.522185 40.52022)
#> 5 mediseh_cymodocea_pnt.5 0 Spagna POINT (0.503069 40.49445)
#> 6 mediseh_cymodocea_pnt.6 0 Spagna POINT (0.502418 40.47931)
#> 7 mediseh_cymodocea_pnt.7 0 Spagna POINT (0.463433 40.45048)
#> 8 mediseh_cymodocea_pnt.8 0 Spagna POINT (0.449706 40.43236)
#> 9 mediseh_cymodocea_pnt.9 0 Spagna POINT (0.445039 40.41589)
#> 10 mediseh_cymodocea_pnt.10 0 Spagna POINT (0.425821 40.3975)
Created on 2022-03-02 by the reprex package (v2.0.1)
Or maybe the problem is with the web service, though 🤔 I'll come back to this tomorrow. 👀
sounds i've a bug with the headers argument, I will look at it asap and let you know
should be fixed with #61