Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cash-loan-flow-boss
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QG
cash-loan-flow-boss
Commits
4b1ededd
Commit
4b1ededd
authored
Jan 02, 2020
by
shangying
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sonar问题修改12
parent
f349304a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
49 deletions
+44
-49
EnvUtil.java
...java/cn/quantgroup/cashloanflowboss/utils/ci/EnvUtil.java
+16
-10
HttpService.java
...n/quantgroup/cashloanflowboss/utils/http/HttpService.java
+28
-39
No files found.
src/main/java/cn/quantgroup/cashloanflowboss/utils/ci/EnvUtil.java
View file @
4b1ededd
...
@@ -113,16 +113,19 @@ public class EnvUtil {
...
@@ -113,16 +113,19 @@ public class EnvUtil {
Set
<
Map
.
Entry
<
Object
,
Object
>>
propertySet
=
propertys
.
entrySet
();
Set
<
Map
.
Entry
<
Object
,
Object
>>
propertySet
=
propertys
.
entrySet
();
for
(
Map
.
Entry
<
Object
,
Object
>
property
:
propertySet
)
{
for
(
Map
.
Entry
<
Object
,
Object
>
property
:
propertySet
)
{
String
propertyKey
=
property
.
getKey
().
toString
();
String
propertyKey
=
property
.
getKey
().
toString
();
String
lowerCase
=
ciEnv
.
toLowerCase
();
if
(
StringUtils
.
isBlank
(
lowerCase
)){
if
(
StringUtils
.
isBlank
(
ciEnv
.
toLowerCase
()
)){
return
env
;
return
env
;
}
}
else
{
String
lowerCase
=
ciEnv
.
toLowerCase
();
if
(
propertyKey
.
toLowerCase
().
contains
(
String
.
format
(
"dubbo.%s.%s."
,
siteName
.
toLowerCase
(),
lowerCase
)))
{
if
(
propertyKey
.
toLowerCase
().
contains
(
String
.
format
(
"dubbo.%s.%s."
,
siteName
.
toLowerCase
(),
lowerCase
)))
{
// �������÷���
// �������÷���
env
=
propertyKey
.
split
(
"\\."
)[
2
];
env
=
propertyKey
.
split
(
"\\."
)[
2
];
break
;
break
;
}
}
}
}
}
}
else
{
}
else
{
return
env
;
return
env
;
}
}
...
@@ -141,16 +144,19 @@ public class EnvUtil {
...
@@ -141,16 +144,19 @@ public class EnvUtil {
Set
<
Map
.
Entry
<
Object
,
Object
>>
propertySet
=
propertys
.
entrySet
();
Set
<
Map
.
Entry
<
Object
,
Object
>>
propertySet
=
propertys
.
entrySet
();
for
(
Map
.
Entry
<
Object
,
Object
>
property
:
propertySet
)
{
for
(
Map
.
Entry
<
Object
,
Object
>
property
:
propertySet
)
{
String
propertyKey
=
property
.
getKey
().
toString
();
String
propertyKey
=
property
.
getKey
().
toString
();
String
lowerCase
=
ciEnv
.
toLowerCase
();
if
(
StringUtils
.
isBlank
(
lowerCase
)){
if
(
StringUtils
.
isBlank
(
ciEnv
.
toLowerCase
()
)){
return
env
;
return
env
;
}
}
else
{
String
lowerCase
=
ciEnv
.
toLowerCase
();
if
(
propertyKey
.
toLowerCase
().
contains
(
String
.
format
(
"http.%s.%s."
,
siteName
.
toLowerCase
(),
lowerCase
)))
{
if
(
propertyKey
.
toLowerCase
().
contains
(
String
.
format
(
"http.%s.%s."
,
siteName
.
toLowerCase
(),
lowerCase
)))
{
// �������÷���,�����ַ�������Сд
// �������÷���,�����ַ�������Сд
env
=
propertyKey
.
split
(
"\\."
)[
2
];
env
=
propertyKey
.
split
(
"\\."
)[
2
];
break
;
break
;
}
}
}
}
}
}
else
{
}
else
{
return
env
;
return
env
;
}
}
...
...
src/main/java/cn/quantgroup/cashloanflowboss/utils/http/HttpService.java
View file @
4b1ededd
...
@@ -138,49 +138,33 @@ public class HttpService {
...
@@ -138,49 +138,33 @@ public class HttpService {
||
!
urlString
.
startsWith
(
httpUrl
))
{
// 如果urlString为null或者urlString为空,或urlString非http开头,返回src空值
||
!
urlString
.
startsWith
(
httpUrl
))
{
// 如果urlString为null或者urlString为空,或urlString非http开头,返回src空值
return
resultEntity
;
return
resultEntity
;
}
}
CloseableHttpResponse
response
=
null
;
CloseableHttpResponse
response
=
null
;
HttpGet
httpGet
=
null
;
HttpGet
httpGet
=
null
;
urlString
=
urlString
.
trim
();
urlString
=
urlString
.
trim
();
try
{
try
{
URL
url
=
new
URL
(
urlString
);
URL
url
=
new
URL
(
urlString
);
//System.out.println(url.getProtocol());
//System.out.println(url.getAuthority());
//System.out.println(url.getPath());
//System.out.println(url.getQuery());
URI
uri
=
new
URI
(
url
.
getProtocol
(),
url
.
getAuthority
(),
url
.
getPath
(),
URI
uri
=
new
URI
(
url
.
getProtocol
(),
url
.
getAuthority
(),
url
.
getPath
(),
url
.
getQuery
(),
null
);
url
.
getQuery
(),
null
);
httpGet
=
new
HttpGet
(
uri
);
httpGet
=
new
HttpGet
(
uri
);
System
.
out
.
println
(
"请求的uri是:"
+
uri
);
if
(
headerInfo
!=
null
&&
!
Objects
.
isNull
(
httpGet
)){
if
(
headerInfo
!=
null
&&
!
Objects
.
isNull
(
httpGet
)){
setHttpHeaderInfo
(
httpGet
,
headerInfo
);
setHttpHeaderInfo
(
httpGet
,
headerInfo
);
}
}
CookieStore
cookieStore
=
new
BasicCookieStore
();
CookieStore
cookieStore
=
new
BasicCookieStore
();
HttpContext
localContext
=
new
BasicHttpContext
();
HttpContext
localContext
=
new
BasicHttpContext
();
localContext
.
setAttribute
(
ClientContext
.
COOKIE_STORE
,
cookieStore
);
localContext
.
setAttribute
(
ClientContext
.
COOKIE_STORE
,
cookieStore
);
try
{
// 执行请求
// 执行请求
try
{
if
(
urlString
.
startsWith
(
httpsUrl
))
{
if
(
urlString
.
startsWith
(
httpsUrl
))
{
System
.
setProperty
(
"jsse.enableSNIExtension"
,
"false"
);
System
.
setProperty
(
"jsse.enableSNIExtension"
,
"false"
);
if
(
filePath
==
null
){
if
(
filePath
==
null
){
response
=
createSSLClientDefault
().
execute
(
httpGet
,
localContext
);
response
=
createSSLClientDefault
().
execute
(
httpGet
,
localContext
);
}
else
{
}
else
{
response
=
createSSLClient
(
filePath
,
pwd
).
execute
(
response
=
createSSLClient
(
filePath
,
pwd
).
execute
(
httpGet
,
localContext
);
httpGet
,
localContext
);
}
}
}
else
{
}
else
{
response
=
httpService
.
getHttpClient
().
execute
(
httpGet
,
localContext
);
response
=
httpService
.
getHttpClient
().
execute
(
httpGet
,
localContext
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
// e.printStackTrace();
log
.
info
(
"异常信息e={}"
,
e
);
log
.
info
(
"异常信息e={}"
,
e
);
}
}
if
(
Objects
.
isNull
(
response
)){
if
(
Objects
.
isNull
(
response
)){
...
@@ -188,25 +172,23 @@ public class HttpService {
...
@@ -188,25 +172,23 @@ public class HttpService {
return
resultEntity
;
return
resultEntity
;
}
else
{
}
else
{
result
=
doResponse
(
response
,
urlString
);
result
=
doResponse
(
response
,
urlString
);
resultEntity
.
setResponseString
(
result
);
resultEntity
.
setCookies
(
cookieStore
.
getCookies
());
// 得到响应状态码
// 得到响应状态码
if
(!
Objects
.
isNull
(
response
.
getStatusLine
()))
{
if
(!
Objects
.
isNull
(
response
.
getStatusLine
()))
{
resultEntity
.
setStatusCode
(
response
.
getStatusLine
().
getStatusCode
());
resultEntity
.
setStatusCode
(
response
.
getStatusLine
().
getStatusCode
());
}
else
{
return
resultEntity
;
}
}
resultEntity
.
setResponseString
(
result
);
resultEntity
.
setCookies
(
cookieStore
.
getCookies
());
}
}
}
catch
(
MalformedURLException
e
)
{
}
catch
(
MalformedURLException
e
)
{
// e.printStackTrace();
log
.
info
(
"异常信息e={}"
,
e
);
log
.
info
(
"异常信息e={}"
,
e
);
}
catch
(
URISyntaxException
e
)
{
}
catch
(
URISyntaxException
e
)
{
// e.printStackTrace();
log
.
info
(
"异常信息e={}"
,
e
);
log
.
info
(
"异常信息e={}"
,
e
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
// e.printStackTrace();
log
.
info
(
"异常信息e={}"
,
e
);
log
.
info
(
"异常信息e={}"
,
e
);
}
finally
{
}
finally
{
...
@@ -215,14 +197,12 @@ public class HttpService {
...
@@ -215,14 +197,12 @@ public class HttpService {
response
.
close
();
response
.
close
();
httpGet
.
abort
();
httpGet
.
abort
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
// e.printStackTrace();
log
.
info
(
"异常信息e={}"
,
e
);
log
.
info
(
"异常信息e={}"
,
e
);
}
}
}
}
}
}
return
resultEntity
;
return
resultEntity
;
}
}
...
@@ -290,12 +270,14 @@ public class HttpService {
...
@@ -290,12 +270,14 @@ public class HttpService {
return
resultEntity
;
return
resultEntity
;
}
else
{
}
else
{
result
=
doResponse
(
response
,
url
);
result
=
doResponse
(
response
,
url
);
resultEntity
.
setResponseString
(
result
);
resultEntity
.
setCookies
(
cookieStore
.
getCookies
());
if
(!
Objects
.
isNull
(
response
.
getStatusLine
())
)
{
if
(!
Objects
.
isNull
(
response
.
getStatusLine
())
)
{
resultEntity
.
setStatusCode
(
response
.
getStatusLine
().
getStatusCode
());
resultEntity
.
setStatusCode
(
response
.
getStatusLine
().
getStatusCode
());
}
else
{
return
resultEntity
;
}
}
resultEntity
.
setResponseString
(
result
);
resultEntity
.
setCookies
(
cookieStore
.
getCookies
());
}
}
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
// ex.printStackTrace();
// ex.printStackTrace();
...
@@ -357,21 +339,27 @@ public class HttpService {
...
@@ -357,21 +339,27 @@ public class HttpService {
log
.
info
(
"异常信息e={}"
,
e
);
log
.
info
(
"异常信息e={}"
,
e
);
}
}
result
=
doResponse
(
response
,
url
);
result
=
doResponse
(
response
,
url
);
if
(
StringUtils
.
isNotEmpty
(
url
)&&
StringUtils
.
isNotEmpty
(
response
.
toString
())){
resultEntity
.
setCookies
(
cookieStore
.
getCookies
());
if
(
response
==
null
){
if
(
StringUtils
.
isNotEmpty
(
url
)){
if
(
StringUtils
.
isNotEmpty
(
response
.
toString
())){
log
.
info
(
"请求超时,最大超时时间:{},url:{}"
,
CommonConstant
.
HTTPCLIENT_CONNECT_TIMEOUT
,
url
);
log
.
info
(
"请求超时,最大超时时间:{},url:{}"
,
CommonConstant
.
HTTPCLIENT_CONNECT_TIMEOUT
,
url
);
return
resultEntity
;
return
resultEntity
;
}
}
// 得到响应状态码
// 得到响应状态码
i
nt
statuCode
=
response
.
getStatusLine
().
getStatusCode
();
i
f
(!
Objects
.
isNull
(
response
.
getStatusLine
()))
{
// 根据状态码进行逻辑处理
// 根据状态码进行逻辑处理
int
statuCode
=
response
.
getStatusLine
().
getStatusCode
();
result
=
getReslut
(
statuCode
,
url
,
response
);
result
=
getReslut
(
statuCode
,
url
,
response
);
System
.
out
.
println
(
">>>>>>>>>>>>>>>>>>>>>"
);
System
.
out
.
println
(
"打印获取的result: "
+
result
);
System
.
out
.
println
(
"打印获取的result: "
+
result
);
}
resultEntity
.
setResponseString
(
result
);
resultEntity
.
setResponseString
(
result
);
resultEntity
.
setCookies
(
cookieStore
.
getCookies
());
resultEntity
.
setStatusCode
(
response
.
getStatusLine
().
getStatusCode
());
resultEntity
.
setStatusCode
(
response
.
getStatusLine
().
getStatusCode
());
}
else
{
return
resultEntity
;
}
}
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
ex
.
printStackTrace
();
}
}
...
@@ -405,7 +393,8 @@ public class HttpService {
...
@@ -405,7 +393,8 @@ public class HttpService {
}
}
}
}
log
.
info
(
"获取实体的文本buffer:{} "
,
buffer
);
log
.
info
(
"获取实体的文本buffer:{} "
,
buffer
);
if
(
StringUtils
.
isBlank
(
charset1
)
||
"zh-cn"
.
equalsIgnoreCase
(
charset1
))
{
String
ecodezc
=
"zh-cn"
;
if
(
StringUtils
.
isBlank
(
charset1
)
||
ecodezc
.
equalsIgnoreCase
(
charset1
))
{
System
.
out
.
println
(
"charset1的值有问题: "
+
charset1
);
System
.
out
.
println
(
"charset1的值有问题: "
+
charset1
);
charset1
=
getCharsetFromMetaTag
(
buffer
,
url
);
charset1
=
getCharsetFromMetaTag
(
buffer
,
url
);
}
else
{
}
else
{
...
...
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