Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ Authors@R: c(
person("Trantor Standard Systems", role = "cph",
comment = "base64 implementation"),
person("Igor", "Sysoev", role = "cph",
comment = "http-parser")
comment = "http-parser"),
person("Mauricio", "Vargas Sepulveda", role = "aut",
comment = c(ORCID = "0000-0003-1017-7574")
)
)
Description: Provides low-level socket and protocol support for handling
HTTP and WebSocket requests directly from within R. It is primarily
Expand All @@ -60,7 +63,6 @@ Imports:
later (>= 0.8.0),
promises,
R6,
Rcpp (>= 1.0.7),
utils
Suggests:
callr,
Expand All @@ -69,21 +71,20 @@ Suggests:
testthat (>= 3.0.0),
websocket
LinkingTo:
later,
Rcpp
later
Config/Needs/website: tidyverse/tidytemplate
Config/testthat/edition: 3
Config/usethis/last-upkeep: 2025-07-01
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.3
SystemRequirements: GNU make, zlib
Collate:
'RcppExports.R'
'httpuv-package.R'
'httpuv.R'
'random_port.R'
'rapi.R'
'server.R'
'staticServer.R'
'static_paths.R'
'utils.R'
Config/roxygen2/version: 8.0.0
9 changes: 1 addition & 8 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@ S3method(print,staticPath)
S3method(print,staticPathOptions)
export(WebSocket)
export(as.staticPath)
export(decodeURI)
export(decodeURIComponent)
export(encodeURI)
export(encodeURIComponent)
export(excludeStaticPath)
export(getRNGState)
export(interrupt)
export(ipFamily)
export(listServers)
export(randomPort)
export(rawToBase64)
Expand All @@ -32,12 +26,11 @@ export(stopAllServers)
export(stopDaemonizedServer)
export(stopServer)
importFrom(R6,R6Class)
importFrom(Rcpp,evalCpp)
importFrom(later,run_now)
importFrom(promises,"%...!%")
importFrom(promises,"%...>%")
importFrom(promises,finally)
importFrom(promises,is.promise)
importFrom(promises,promise)
importFrom(promises,then)
useDynLib(httpuv, .registration = TRUE)
useDynLib(httpuv, .registration = TRUE, .fixes = "C_")
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# httpuv (development version)

# httpuv 1.6.16.9000

* @pachadotdev: Changed all the code to rely 100% on R's C API.

* Closed #426: Uses native symbol registration for calls into compiled code, resulting in performance gains from not having to perform a lookup on each call. (#427)

* Fixed installation failures on macOS caused by the bundled libuv build trying to regenerate autotools files when only some tools (e.g., automake) are present. (#430)
Expand Down
147 changes: 0 additions & 147 deletions R/RcppExports.R

This file was deleted.

3 changes: 1 addition & 2 deletions R/httpuv-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
#' @title HTTP and WebSocket server
#' @author Joe Cheng \email{joe@@rstudio.com}
#' @keywords package
#' @useDynLib httpuv, .registration = TRUE
#' @useDynLib httpuv, .registration = TRUE, .fixes = "C_"
"_PACKAGE"

## usethis namespace: start
#' @importFrom Rcpp evalCpp
#' @importFrom promises promise then finally is.promise %...>% %...!%
#' @importFrom later run_now
#' @importFrom R6 R6Class
Expand Down
87 changes: 87 additions & 0 deletions R/rapi.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
sendWSMessage <- function(conn, binary, message) {
invisible(.Call(C_sendWSMessage, conn, binary, message))
}

closeWS <- function(conn, code, reason) {
invisible(.Call(C_closeWS, conn, as.integer(code), reason))
}

makeTcpServer <- function(host, port, onHeaders, onBodyData, onRequest,
onWSOpen, onWSMessage, onWSClose,
staticPaths, staticPathOptions, quiet) {
.Call(C_makeTcpServer, host, as.integer(port), onHeaders, onBodyData,
onRequest, onWSOpen, onWSMessage, onWSClose,
staticPaths, staticPathOptions, quiet)
}

makePipeServer <- function(name, mask, onHeaders, onBodyData, onRequest,
onWSOpen, onWSMessage, onWSClose,
staticPaths, staticPathOptions, quiet) {
.Call(C_makePipeServer, name, as.integer(mask), onHeaders, onBodyData,
onRequest, onWSOpen, onWSMessage, onWSClose,
staticPaths, staticPathOptions, quiet)
}

stopServer_ <- function(handle) {
invisible(.Call(C_stopServer_, handle))
}

getStaticPaths_ <- function(handle) {
.Call(C_getStaticPaths_, handle)
}

setStaticPaths_ <- function(handle, sp) {
.Call(C_setStaticPaths_, handle, sp)
}

removeStaticPaths_ <- function(handle, paths) {
.Call(C_removeStaticPaths_, handle, paths)
}

getStaticPathOptions_ <- function(handle) {
.Call(C_getStaticPathOptions_, handle)
}

setStaticPathOptions_ <- function(handle, opts) {
.Call(C_setStaticPathOptions_, handle, opts)
}

rawToBase64 <- function(x) {
.Call(C_base64encode, x)
}

encodeURI <- function(value) {
.Call(C_encodeURI, value)
}

encodeURIComponent <- function(value) {
.Call(C_encodeURIComponent, value)
}

decodeURI <- function(value) {
.Call(C_decodeURI, value)
}

decodeURIComponent <- function(value) {
.Call(C_decodeURIComponent, value)
}

ipFamily <- function(ip) {
.Call(C_ipFamily, ip)
}

invokeCppCallback <- function(data, callback_xptr) {
invisible(.Call(C_invokeCppCallback, data, callback_xptr))
}

getRNGState <- function() {
invisible(.Call(C_getRNGState))
}

wsconn_address <- function(external_ptr) {
.Call(C_wsconn_address, external_ptr)
}

log_level <- function(level) {
.Call(C_log_level, level)
}
9 changes: 6 additions & 3 deletions R/static_paths.R
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,15 @@ normalizeStaticPathOptions <- function(opts) {
# side, we want a named character vector.
if (is.list(opts$headers)) {
# Convert list to named character vector
opts$headers <- unlist(opts$headers, recursive = FALSE)
new_headers <- unlist(opts$headers, recursive = FALSE)
# Special case: if opts$headers was an empty list before unlist(), it is
# now NULL. Replace it with an empty named character vector.
if (length(opts$headers) == 0) {
opts$headers <- c(a = "a")[0]
if (length(new_headers) == 0) {
new_headers <- c(a = "a")[0]
}
# Assign in place to preserve list element order (assigning NULL would
# remove the element).
opts$headers <- new_headers

if (!is.character(opts$headers) || any_unnamed(opts$headers)) {
stop("`headers` option must be a named list or character vector.")
Expand Down
Loading