Skip to content

Commit b4d0767

Browse files
authored
Merge pull request #23 from jwebbsoma/master
fixed logical error for GET requests
2 parents ade3c6c + 687151e commit b4d0767

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

R/plumber_handler.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ default_error_handler <- function(req, res, error) {
5959
#' @export
6060
wrap_error_handler_with_sentry <- function(error_handler = default_error_handler) {
6161
function(req, res, error, ...) {
62-
if (!is.null(req$postBody) && length(req$postBody) > 0 && grepl(pattern = "application/json", x = req$HTTP_CONTENT_TYPE, fixed = T) ) {
62+
http_content_type <- ifelse(is.null(req$HTTP_CONTENT_TYPE), "", req$HTTP_CONTENT_TYPE)
63+
if (!is.null(req$postBody) && length(req$postBody) > 0 && grepl(pattern = "application/json", x = http_content_type, fixed = T) ) {
6364
req_body <- list(
6465
data = lapply(jsonlite::fromJSON(req$postBody), function(x) utils::head(x, 10))
6566
)
@@ -72,7 +73,7 @@ wrap_error_handler_with_sentry <- function(error_handler = default_error_handler
7273
query_string = req$QUERY_STRING,
7374
method = req$REQUEST_METHOD,
7475
headers = list(
75-
`content-type` = req$HTTP_CONTENT_TYPE
76+
`content-type` = http_content_type
7677
),
7778
env = list(
7879
REMOTE_ADDR = ifelse(

0 commit comments

Comments
 (0)