From 98d5b4e72a3c9a98ad69e33f7f62c86027b5ab6c Mon Sep 17 00:00:00 2001 From: Alassane Samba Date: Mon, 4 Dec 2017 01:22:14 +0100 Subject: [PATCH 1/2] cookie format --- R/response.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/response.R b/R/response.R index 6d000423f..4b5259fec 100644 --- a/R/response.R +++ b/R/response.R @@ -65,14 +65,14 @@ cookieToStr <- function(name, value, path, expiration=FALSE, http=FALSE, secure= expy <- now + expiration expyStr <- format(expy, format="%a, %e %b %Y %T", tz="GMT", usetz=TRUE) - str <- paste0(str, "Expires: ", expyStr, "; ") - str <- paste0(str, "Max-Age: ", expiration, "; ") + str <- paste0(str, "Expires= ", expyStr, "; ") + str <- paste0(str, "Max-Age= ", expiration, "; ") } else if (inherits(expiration, "POSIXt")){ seconds <- difftime(expiration, Sys.time(), units="secs") # TODO: DRY expyStr <- format(expiration, format="%a, %e %b %Y %T", tz="GMT", usetz=TRUE) - str <- paste0(str, "Expires: ", expyStr, "; ") - str <- paste0(str, "Max-Age: ", as.integer(seconds), "; ") + str <- paste0(str, "Expires= ", expyStr, "; ") + str <- paste0(str, "Max-Age= ", as.integer(seconds), "; ") } # interpret all other values as session cookies. } From 46eaaafa730495d4737d4128389df5dece674ebd Mon Sep 17 00:00:00 2001 From: Alassane Samba Date: Mon, 4 Dec 2017 01:25:11 +0100 Subject: [PATCH 2/2] cookie format on test --- tests/testthat/test-cookies.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test-cookies.R b/tests/testthat/test-cookies.R index 3a5b850dd..1330060b8 100644 --- a/tests/testthat/test-cookies.R +++ b/tests/testthat/test-cookies.R @@ -43,11 +43,11 @@ test_that("cookies can convert to string", { # line above and below. # When given as a number of seconds expect_equal(cookieToStr("abc", 123, expiration=expiresSec), - paste0("abc=123; Expires: ", expyStr, "; Max-Age: ", expiresSec)) + paste0("abc=123; Expires= ", expyStr, "; Max-Age= ", expiresSec)) # When given as a POSIXct # difftime is exclusive, so the Max-Age may be off by one on positive time diffs. expect_equal(cookieToStr("abc", 123, expiration=expires), - paste0("abc=123; Expires: ", expyStr, "; Max-Age: ", expiresSec-1)) + paste0("abc=123; Expires= ", expyStr, "; Max-Age= ", expiresSec-1)) # Works with a negative number of seconds expiresSec <- -10 @@ -57,10 +57,10 @@ test_that("cookies can convert to string", { # line above and below. # When given as a number of seconds expect_equal(cookieToStr("abc", 123, expiration=expiresSec), - paste0("abc=123; Expires: ", expyStr, "; Max-Age: ", expiresSec)) + paste0("abc=123; Expires= ", expyStr, "; Max-Age= ", expiresSec)) # When given as a POSIXct expect_equal(cookieToStr("abc", 123, expiration=expires), - paste0("abc=123; Expires: ", expyStr, "; Max-Age: ", expiresSec)) + paste0("abc=123; Expires= ", expyStr, "; Max-Age= ", expiresSec)) })