Commit 40647168 authored by Laura A DeCicco's avatar Laura A DeCicco
Browse files

Trying to get targets and proxies to work

parent 0833a037
......@@ -84,6 +84,9 @@ getWebServiceData <- function(obs_url, ...){
}
}
#' Create user agent
#'
#' @keywords internal
default_ua <- function() {
versions <- c(
libcurl = curl::curl_version()$version,
......@@ -100,6 +103,24 @@ default_ua <- function() {
return(ua)
}
#' has_internet2
#'
#' Function to check for internet even if the user
#' is behind a proxy
#'
#' @keywords internal
#' @param obs_url character obs_url to check
has_internet_2 <- function(obs_url) {
# For now, we know exactly where we're sending our queries
# But, if we expose a setter, we'll probably need to move it
# to the url construction, set a host in the package enviornment?,
# or come up with some better regex here:
host <- gsub("^https://(?:www[.])?([^/]*).*$", "\\1", obs_url )
!is.null(curl::nslookup(host, error = FALSE))
}
#' getting header information from a WQP query
#'
#'@param url the query url
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/getWebServiceData.R
\name{default_ua}
\alias{default_ua}
\title{Create user agent}
\usage{
default_ua()
}
\description{
Create user agent
}
\keyword{internal}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/getWebServiceData.R
\name{has_internet_2}
\alias{has_internet_2}
\title{has_internet2}
\usage{
has_internet_2(obs_url)
}
\arguments{
\item{obs_url}{character obs_url to check}
}
\description{
Function to check for internet even if the user
is behind a proxy
}
\keyword{internal}
......@@ -49,10 +49,10 @@ test_that("General NWIS retrievals working", {
expect_is(waterYearStat$parameter_cd,"character")
#Empty data
# note....not empty anymore!
urlTest <- "https://nwis.waterservices.usgs.gov/nwis/iv/?site=11447650&format=waterml,1.1&ParameterCd=63680&startDT=2016-12-13&endDT=2016-12-13"
x <- importWaterML1(urlTest)
expect_equal(names(x), c("agency_cd","site_no","dateTime","tz_cd"))
expect_true(all(c("agency_cd","site_no","dateTime","tz_cd") %in% names(x)))
#Test list:
args <- list(sites="05114000", service="iv",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment