-
Notifications
You must be signed in to change notification settings - Fork 15
UpdaterUtil: follow HTTP redirects (issue #65) #67
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
base: master
Are you sure you want to change the base?
Conversation
Recursively follow redirects in case of 301, 302, and 307 codes. Make construction of user agent value separate to avoid repeated calls.
I just noticed that while this means that the redirect is used to get the |
Setting this before making the connection avoids the Already Connected error but I don't know how :/
…ection already happened Because the connection is already done (in openConnection so it can identify a redirect), we can't change the request Method.
I think I found all the issues and seems to be working now. The problem is that |
…ion already happened Because the connection is already done (in openConnection so it can identify a redirect), we can't change the request Method.
There was one other case where it tried to modify the open connection which I removed now. An alternative to not have the backwards incompatible issue, is to have openConnection follow any redirects, and then open a new connection with the final URL once there's no more redirects to do. |
ping? |
@frauzufall What do you think? Should we merge this? |
It's time for sure ;-) I did not already do it because of this note:
I like the proposed (not yet implemented) solution by @carandraug to follow redirects and then reopen the connection with the final URL, but that would mean we would have twice as many update requests as we currently have. What do you think about that @ctrueden? In case you agree, I'd like to add this and clean up the commits. How can I do this best if I don't have permission to write to the branch, just work with @carandraug's commits on a new branch in this repo? |
@frauzufall wrote:
If @carandraug left this little box "Allow edits from maintainers" checked (which by default it is) when opening the PR, you should have push permission to this branch. Did you try? Concerning the number of update requests: that's only true for installations that still have http configured and have to follow the redirect, right? Installations with an updated https URL (i.e. no redirect needed) could proceed with the original connection, no? |
Our move from HTTP to HTTPS does not involve redirects. This PR is relevant to sites not hosted on imagej.net which could include redirects. The Another (non backwards compatible) idea is to add a
Awesome, sorry I did not know about that, will try. |
Maybe relevant to the discussion:
So I'm leaning towards having two new methods ( |
Regarding doubling the number of requests, I do not feel strongly. And HEAD requests are fast. But I am no expert on web performance so maybe it is not a good idea. It seems intuitively obvious that if we can avoid the second request in the common case where no redirect needs to be followed, we should do so. |
@frauzufall wrote:
URL redirection is pretty standard. If imagej.net ever needs to be I don't think I can offer much more input. Would be nice to see this |
Recursively follow redirects in case of 301, 302, and 307 codes. Make
construction of user agent value separate to avoid repeated calls.
This seems to fix the issue for the case of the SIMcheck update site which is how I'm testing it. However, it seems to have introduced another bug which I can't make sense of. To reproduce this new issue:
Reading online, this seems to often be caused by reusing HttpURLConnection but it doesn't look like I've doing it (but I'm not much of a Java developer and I may be missing something obvious).