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

libCurl HTTP handler doesn't handle redirects #674

Closed
hadley opened this issue Feb 16, 2023 · 5 comments · Fixed by #754
Closed

libCurl HTTP handler doesn't handle redirects #674

hadley opened this issue Feb 16, 2023 · 5 comments · Fixed by #754
Labels
bug an unexpected problem or unintended behavior libcurl 🕸️

Comments

@hadley
Copy link
Member

hadley commented Feb 16, 2023

Because of

curl::handle_setopt(handle, followlocation = FALSE)

This is probably low-priority, but it caused a confusing error for me when attempting to publish to colarado.rstudio.com which has been renamed to colorado.posit.co

@hadley hadley changed the title libCurl HTTP handler doesn't to handle redirects libCurl HTTP handler doesn' handle redirects Feb 16, 2023
@hadley hadley changed the title libCurl HTTP handler doesn' handle redirects libCurl HTTP handler doesn't handle redirects Feb 16, 2023
@hadley hadley added bug an unexpected problem or unintended behavior libcurl 🕸️ labels Feb 21, 2023
@hadley
Copy link
Member Author

hadley commented Mar 1, 2023

Need to resolve why deployApp("tests/testthat/shinyapp-appR", server = "shinyapps.io") errors when it's removed.

@aronatkins
Copy link
Contributor

@hadley the redirect probably does not receive the necessary authentication information.

@aronatkins
Copy link
Contributor

Second option: The payload may not be attached to the redirect.

@hadley
Copy link
Member Author

hadley commented Mar 1, 2023

The error happens in updateBundleStatus() which returns

> POST /v1/bundles/6903688/status HTTP/2

< HTTP/2 303 
< date: Wed, 01 Mar 2023 18:56:21 GMT
< content-type: text/html; charset=UTF-8
< content-length: 0
< location: https://api.shinyapps.io/v1/bundles/6903688
< server: TornadoServer/6.2

This possibly works by coincidence with redirects disabled, it appears to be a successful request.

I'm not sure why shinyapps.io returns a temporary redirect here, but if I instead send the request to /v1/bundles/6903688, I get a 500 server error.

@hadley
Copy link
Member Author

hadley commented Mar 8, 2023

Can remove these lines once redirects work automatically:

rsconnect/R/ide.R

Lines 56 to 67 in 5103b90

if (httpResponse$status == 307 &&
!is.null(httpResponse$location)) {
# we were served a redirect; try again with the new URL
url <- httpResponse$location
if (substring(url, (nchar(url) - nchar(settingsEndpoint)) + 1) ==
settingsEndpoint) {
# chop /server_settings from the redirect path to get the raw API path
url <- substring(url, 1, nchar(url) - nchar(settingsEndpoint))
}
next
}

hadley added a commit that referenced this issue Mar 9, 2023
hadley added a commit that referenced this issue Mar 13, 2023
Redirects are now handled in `httpRequest()` and `httpRequestWithBody()` (Fixes #674), and allows for a much simpler `validateConnectUrl()`. I also simplified `httpLibCurl()` to use the same upload method for `PUT` and `POST` and removed outdated error handling (Fixes #450). Includes some minor feedback improvements when uploading large apps.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior libcurl 🕸️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants