Skip to content
This repository has been archived by the owner on Feb 7, 2025. It is now read-only.

Commit

Permalink
Attempt to fix issue #7 making the requested changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
blasee committed Jan 8, 2017
1 parent c2c5344 commit c8b1a10
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
3 changes: 3 additions & 0 deletions R/cfQuery.R
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ cf_query = function(user, datatype, station, start_date, end_date = now(tz),
.params = all_dt_params,
curl = curl,
.opts = list(cainfo = cert))

if (is.raw(doc))
doc = rawToChar(doc)

is_HTML = grepl("<!DOCTYPE HTML PUBLIC", doc, fixed = TRUE)
if (is_HTML){
Expand Down
21 changes: 12 additions & 9 deletions R/cfUser.R
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,18 @@ cf_logout = function(object, msg = TRUE){

header = getURLContent("https://cliflo.niwa.co.nz/pls/niwp/wa.logout",
curl = curl, header = TRUE, cainfo = cert)
if (!grepl("OK", header$header["statusMessage"]))
stop("HTTP error")

getURL("https://cliflo.niwa.co.nz/pls/niwp/wa.logout",
curl = curl, cainfo = cert)

file.remove(cookies)
if (msg)
message("Logout successful")

if (header$header["status"] != 200){
file.remove(cookies)
warning("HTTP status was not '200' when logging out")
} else {
getURL("https://cliflo.niwa.co.nz/pls/niwp/wa.logout",
curl = curl, cainfo = cert)

file.remove(cookies)
if (msg)
message("Logout successful")
}
}

#' @rdname valid_cfuser
Expand Down

0 comments on commit c8b1a10

Please sign in to comment.