Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TensorFlow Manager
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bioimage Analysis
TensorFlow Manager
Commits
1c8100d3
Commit
1c8100d3
authored
1 year ago
by
carlosuc3m
Browse files
Options
Downloads
Patches
Plain Diff
add redirection of URLs
parent
69afd529
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/bioimageanalysis/icy/deeplearning/versionmanager/downloading/DeepLearningVersionDownloader.java
+33
-1
33 additions, 1 deletion
...ionmanager/downloading/DeepLearningVersionDownloader.java
with
33 additions
and
1 deletion
src/main/java/org/bioimageanalysis/icy/deeplearning/versionmanager/downloading/DeepLearningVersionDownloader.java
+
33
−
1
View file @
1c8100d3
...
...
@@ -7,6 +7,7 @@ import java.io.FileOutputStream;
import
java.io.IOException
;
import
java.net.HttpURLConnection
;
import
java.net.MalformedURLException
;
import
java.net.URISyntaxException
;
import
java.net.URL
;
import
java.nio.channels.Channels
;
import
java.nio.channels.ReadableByteChannel
;
...
...
@@ -261,7 +262,8 @@ public class DeepLearningVersionDownloader
{
HttpURLConnection
httpConnection
=
(
HttpURLConnection
)
(
url
.
openConnection
());
while
(
httpConnection
.
getResponseCode
()
==
302
)
{
url
=
new
URL
(
httpConnection
.
getHeaderField
(
"Location"
));
// TODO use method from JDLL
url
=
redirectedURL
(
url
,
httpConnection
);
httpConnection
=
(
HttpURLConnection
)
(
url
.
openConnection
());
}
long
completeFileSize
=
httpConnection
.
getContentLengthLong
();
...
...
@@ -297,6 +299,36 @@ public class DeepLearningVersionDownloader
}
return
localFilePath
;
}
/**
* TODO replae and use method from JDLL
* @param url
* @param conn
* @return
*/
public
static
URL
redirectedURL
(
URL
url
,
HttpURLConnection
conn
)
{
int
statusCode
;
try
{
statusCode
=
conn
.
getResponseCode
();
}
catch
(
IOException
ex
)
{
return
url
;
}
if
(
statusCode
!=
HttpURLConnection
.
HTTP_MOVED_TEMP
&&
statusCode
!=
HttpURLConnection
.
HTTP_MOVED_PERM
&&
statusCode
!=
HttpURLConnection
.
HTTP_SEE_OTHER
)
return
url
;
String
newURL
=
conn
.
getHeaderField
(
"Location"
);
try
{
return
new
URL
(
newURL
);
}
catch
(
MalformedURLException
ex
)
{
}
try
{
String
mainDomain
=
url
.
toURI
().
getHost
();
return
new
URL
(
mainDomain
+
newURL
);
}
catch
(
URISyntaxException
|
MalformedURLException
e
)
{
return
null
;
}
}
/**
* Retrieves the paths of all resources associated to a given version resolved locally.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment