Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Collector
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Legacy
gitolite
user
iwakeh
Collector
Commits
7b94cd7a
Commit
7b94cd7a
authored
7 years ago
by
iwakeh
Committed by
Karsten Loesing
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Set read timeout on HTTPUrlConnection and some minor tweaks.
Implements task20516.
parent
c531064f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/torproject/collector/exitlists/ExitListDownloader.java
+16
-16
16 additions, 16 deletions
...rg/torproject/collector/exitlists/ExitListDownloader.java
with
16 additions
and
16 deletions
src/main/java/org/torproject/collector/exitlists/ExitListDownloader.java
+
16
−
16
View file @
7b94cd7a
...
...
@@ -71,30 +71,30 @@ public class ExitListDownloader extends CollecTorMain {
EXITLISTS
).
toString
();
Date
downloadedDate
=
new
Date
();
String
downloadedExitList
=
null
;
try
{
logger
.
debug
(
"Downloading exit list..."
);
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
Annotation
.
ExitList
.
toString
());
sb
.
append
(
"Downloaded "
+
dateTimeFormat
.
format
(
downloadedDate
)
+
"\n"
);
URL
url
=
config
.
getUrl
(
Key
.
ExitlistUrl
);
logger
.
debug
(
"Downloading exit list..."
);
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
Annotation
.
ExitList
.
toString
());
sb
.
append
(
"Downloaded "
+
dateTimeFormat
.
format
(
downloadedDate
)
+
"\n"
);
URL
url
=
config
.
getUrl
(
Key
.
ExitlistUrl
);
try
{
HttpURLConnection
huc
=
(
HttpURLConnection
)
url
.
openConnection
();
huc
.
setRequestMethod
(
"GET"
);
huc
.
setReadTimeout
(
5000
);
huc
.
connect
();
int
response
=
huc
.
getResponseCode
();
if
(
response
!=
200
)
{
logger
.
warn
(
"Could not download exit list. Response code
"
+
response
);
logger
.
warn
(
"Could not download exit list. Response code
{}"
,
response
);
return
;
}
BufferedInputStream
in
=
new
BufferedInputStream
(
huc
.
getInputStream
());
int
len
;
byte
[]
data
=
new
byte
[
1024
];
while
((
len
=
in
.
read
(
data
,
0
,
1024
))
>=
0
)
{
sb
.
append
(
new
String
(
data
,
0
,
len
));
try
(
BufferedInputStream
in
=
new
BufferedInputStream
(
huc
.
getInputStream
()))
{
int
len
;
byte
[]
data
=
new
byte
[
1024
];
while
((
len
=
in
.
read
(
data
,
0
,
1024
))
>=
0
)
{
sb
.
append
(
new
String
(
data
,
0
,
len
));
}
}
in
.
close
();
downloadedExitList
=
sb
.
toString
();
logger
.
debug
(
"Finished downloading exit list."
);
}
catch
(
IOException
e
)
{
...
...
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