Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
browser-backend
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
browser-backend
Commits
e7c4e436
Commit
e7c4e436
authored
Jun 08, 2020
by
jim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tran
parent
d8296e81
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
14 deletions
+10
-14
Trans.java
...ain/java/com/edgec/browserbackend/common/utils/Trans.java
+10
-14
No files found.
src/main/java/com/edgec/browserbackend/common/utils/Trans.java
View file @
e7c4e436
package
com
.
edgec
.
browserbackend
.
common
.
utils
;
import
org.apache.commons.io.Charsets
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpHost
;
import
org.apache.http.HttpResponse
;
...
...
@@ -12,12 +13,11 @@ import org.apache.http.client.methods.HttpGet;
import
org.apache.http.impl.client.BasicCredentialsProvider
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.util.EntityUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
public
class
Trans
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
Trans
.
class
);
...
...
@@ -50,7 +50,7 @@ public class Trans {
*/
public
static
void
main
(
String
[]
args
)
{
String
url
=
"http://free.ipwhois.io/json/"
;
Trans
trans
=
new
Trans
(
"
23.105.2.118"
,
"uE5LkzM81UhU
aA1"
);
Trans
trans
=
new
Trans
(
"
112.74.47.217"
,
20001
,
"fangguanlianbrowser"
,
"5D753F36QKqI
aA1"
);
String
rs
=
trans
.
get
(
url
);
System
.
out
.
println
(
rs
);
}
...
...
@@ -84,17 +84,7 @@ public class Trans {
HttpResponse
response
=
client
.
execute
(
httpGet
);
HttpEntity
entry
=
response
.
getEntity
();
if
(
entry
!=
null
)
{
InputStreamReader
is
=
new
InputStreamReader
(
entry
.
getContent
());
BufferedReader
br
=
new
BufferedReader
(
is
);
String
str
=
null
;
while
((
str
=
br
.
readLine
())
!=
null
)
{
sb
.
append
(
str
.
trim
());
}
br
.
close
();
}
return
sb
.
toString
();
return
EntityUtils
.
toString
(
entry
,
Charsets
.
UTF_8
);
}
catch
(
ClientProtocolException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
return
""
;
...
...
@@ -106,6 +96,11 @@ public class Trans {
return
""
;
}
finally
{
httpGet
.
releaseConnection
();
try
{
client
.
close
();
}
catch
(
IOException
e
)
{
logger
.
error
(
"fail to close connection"
,
e
);
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment