Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload seek #745

Closed
wants to merge 4 commits into from
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
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: httr
Title: Tools for Working with URLs and HTTP
Version: 1.4.6.9000
Version: 1.4.7
Authors@R: c(
person("Hadley", "Wickham", , "[email protected]", role = c("aut", "cre")),
person("Posit, PBC", role = c("cph", "fnd"))
Expand All @@ -15,7 +15,7 @@ BugReports: https://github.com/r-lib/httr/issues
Depends:
R (>= 3.5)
Imports:
curl (>= 3.0.0),
curl (>= 5.0.2),
jsonlite,
mime,
openssl (>= 0.8),
Expand All @@ -36,3 +36,4 @@ Config/Needs/website: tidyverse/tidytemplate
Encoding: UTF-8
Roxygen: list(markdown = TRUE, r6 = FALSE)
RoxygenNote: 7.2.3
Remotes: jeroen/curl
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# httr (development version)
# httr 1.4.7

* Suppress another use of httpbin.

Expand Down
6 changes: 6 additions & 0 deletions R/body.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ body_config <- function(body = NULL,
}
bin
},
seekfunction = function(offset, ...) {
if (is.null(con)) {
con <<- file(body$path, "rb")
}
seek(con, where = offset)
},
postfieldsize_large = size
),
content_type(body$type)
Expand Down
4 changes: 4 additions & 0 deletions R/http-get.r
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@
#' @export
#' @examples
#' GET("http://google.com/")
#' \dontrun{
#' GET("http://google.com/", path = "search")
#' GET("http://google.com/", path = "search", query = list(q = "ham"))
#' }
#'
#' # See what GET is doing with httpbin.org
#' \dontrun{
Expand All @@ -62,9 +64,11 @@
#'
#' # You might want to manually specify the handle so you can have multiple
#' # independent logins to the same website.
#' \dontrun{
#' google <- handle("http://google.com")
#' GET(handle = google, path = "/")
#' GET(handle = google, path = "search")
#' }
GET <- function(url = NULL, config = list(), ..., handle = NULL) {
hu <- handle_url(handle, url, ...)
req <- request_build("GET", hu$url, as.request(config), ...)
Expand Down
2 changes: 0 additions & 2 deletions R/oauth-listener.r
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#'
#' @param request_url the url to send the browser to
#' @param is_interactive DEPRECATED
#' @param host ip address for the listener
#' @param port for the listener
#' @export
#' @keywords internal
oauth_listener <- function(request_url, is_interactive = interactive()) {
Expand Down
2 changes: 0 additions & 2 deletions R/oauth-server-side.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ init_oauth_service_account <- function(secrets, scope = NULL, sub = NULL) {
#' @param credentials Parsed contents of the credentials file.
#' @param scope A space-delimited list of the permissions that the application
#' requests.
#' @param iss Email address of the client_id of the application making the
#' access token request.
#' @param scope A space-delimited list of the permissions that the application
#' requests.
#' @param sub The email address of the user for which the application is
Expand Down
5 changes: 2 additions & 3 deletions R/write-function.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#' This S3 object allows you to control how the response body is saved.
#'
#' @param subclass,... Class name and fields. Used in class constructors.
#' @param x A `write_function` object to process.
#' @keywords internal
#' @export
write_function <- function(subclass, ...) {
Expand All @@ -24,10 +23,10 @@ write_function <- function(subclass, ...) {
#' tmp <- tempfile()
#' r1 <- GET("https://www.google.com", write_disk(tmp))
#' readLines(tmp)
#'
#'
#' # The default
#' r2 <- GET("https://www.google.com", write_memory())
#'
#'
#' # Save a very large file
#' \dontrun{
#' GET(
Expand Down
4 changes: 4 additions & 0 deletions man/GET.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions man/jwt_signature.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions man/oauth_listener.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions man/write_function.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions tests/testthat/test-upload-file.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
test_that("can upload with redirect", {
skip_on_cran()

str <- paste(letters, collapse = '')
tmp <- tempfile()
writeBin(str, tmp)

resp <- PUT(
"https://hb.cran.dev/redirect-to?url=/put&status_code=307",
body = upload_file(tmp)
)

expect_equal(resp$status_code, 200)
expect_equal(resp$url, "https://hb.cran.dev/put")
json <- content(resp)
expect_equal(json$data, str)
})
Loading