Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fastdevelop
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
高超
fastdevelop
Commits
54d20ace
Commit
54d20ace
authored
Dec 18, 2019
by
gao.chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
网络请求增加DNS解析
parent
a663a955
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletions
+27
-1
fastDevelop/src/main/java/com/mayi/fastdevelop/okhttp/HttpDns.java
+26
-0
fastDevelop/src/main/java/com/mayi/fastdevelop/okhttp/NetWorkUtil.java
+1
-1
No files found.
fastDevelop/src/main/java/com/mayi/fastdevelop/okhttp/HttpDns.java
0 → 100644
View file @
54d20ace
package
com
.
mayi
.
fastdevelop
.
okhttp
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
okhttp3.Dns
;
public
class
HttpDns
implements
Dns
{
@Override
public
List
<
InetAddress
>
lookup
(
String
hostname
)
{
List
<
InetAddress
>
inetAddresses
=
new
ArrayList
<>();
List
<
InetAddress
>
hostNameInetAddresses
=
null
;
try
{
hostNameInetAddresses
=
Dns
.
SYSTEM
.
lookup
(
hostname
);
}
catch
(
UnknownHostException
e
)
{
e
.
printStackTrace
();
}
if
(
hostNameInetAddresses
!=
null
&&
hostNameInetAddresses
.
size
()
>
0
)
{
inetAddresses
.
addAll
(
hostNameInetAddresses
);
}
return
inetAddresses
;
}
}
\ No newline at end of file
fastDevelop/src/main/java/com/mayi/fastdevelop/okhttp/NetWorkUtil.java
View file @
54d20ace
...
@@ -40,7 +40,7 @@ public class NetWorkUtil {
...
@@ -40,7 +40,7 @@ public class NetWorkUtil {
private
NetWorkUtil
()
{
private
NetWorkUtil
()
{
client
=
new
OkHttpClient
.
Builder
()
client
=
new
OkHttpClient
.
Builder
()
.
connectTimeout
(
60
,
TimeUnit
.
SECONDS
)
.
connectTimeout
(
60
,
TimeUnit
.
SECONDS
)
.
readTimeout
(
60
,
TimeUnit
.
SECONDS
).
build
();
.
readTimeout
(
60
,
TimeUnit
.
SECONDS
).
dns
(
new
HttpDns
()).
build
();
handler
=
new
Handler
(
Looper
.
getMainLooper
());
handler
=
new
Handler
(
Looper
.
getMainLooper
());
}
}
...
...
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