Skip to content

"error: missing value where TRUE/FALSE needed" -- request$get_header() parses dates wrong? #11

@greg-minshall

Description

@greg-minshall

hi. in routr's ressource_route() function, there is a line

m_since <- request$get_header('If-Modified-Since')

it appears get_header returns a vector of length 2, the first being day-name, which is separated by a comma from the second element (day, month, year, ...).

when in the subsequent if statement, m_since is fed to from_http_date(), i'm guessing two NAs result. which, it appears, results in the subject error message.

i took a quick look in the code in request.R, but didn't immediately see where the headers are set (maybe not even in reqres? in fiery? httpuv?).

a hack in routr would be something like

diff --git a/R/ressource_route.R b/R/ressource_route.R
index 02021fe..cb990a9 100644
--- a/R/ressource_route.R
+++ b/R/ressource_route.R
@@ -143,6 +143,10 @@ ressource_route <- function(..., default_file = 'index.html', default_ext = 'htm
       m_time <- file.mtime(real_file)
       etag <- request$get_header('If-None-Match')
       new_tag <- digest(m_time)
+      if (!is.null(m_since)) {
+          m_since <- paste(m_since, collapse=", ")
+      }
       if ((!is.null(m_since) && from_http_date(m_since) < m_time) ||
           (!is.null(etag) && etag == new_tag)) {
         response$status_with_text(304L)

cheers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions