Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
sap-service
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
曲欣亮
sap-service
Commits
7815ba36
Commit
7815ba36
authored
Aug 05, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
9bad7bc7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
3 deletions
+20
-3
HttpUtil.java
src/main/java/com/egolm/sso/util/HttpUtil.java
+17
-2
logback.xml
src/main/resources/logback.xml
+3
-1
No files found.
src/main/java/com/egolm/sso/util/HttpUtil.java
View file @
7815ba36
...
@@ -11,10 +11,15 @@ import java.util.Map;
...
@@ -11,10 +11,15 @@ import java.util.Map;
import
java.util.regex.Matcher
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
java.util.regex.Pattern
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
public
class
HttpUtil
{
public
class
HttpUtil
{
static
Log
logger
=
LogFactory
.
getLog
(
HttpUtil
.
class
);
public
static
String
get
(
String
requestUrl
,
Map
<
String
,
String
>
headers
)
{
public
static
String
get
(
String
requestUrl
,
Map
<
String
,
String
>
headers
)
{
HttpURLConnection
connection
=
null
;
HttpURLConnection
connection
=
null
;
try
{
try
{
...
@@ -76,6 +81,9 @@ public class HttpUtil {
...
@@ -76,6 +81,9 @@ public class HttpUtil {
}
}
public
static
String
post
(
String
requestUrl
,
Map
<
String
,
Object
>
parameters
,
Map
<
String
,
String
>
headers
)
{
public
static
String
post
(
String
requestUrl
,
Map
<
String
,
Object
>
parameters
,
Map
<
String
,
String
>
headers
)
{
logger
.
debug
(
requestUrl
);
logger
.
debug
(
JSON
.
toJSONString
(
parameters
));
logger
.
debug
(
JSON
.
toJSONString
(
headers
));
HttpURLConnection
connection
=
null
;
HttpURLConnection
connection
=
null
;
try
{
try
{
String
requestBody
=
toQueryString
(
parameters
);
String
requestBody
=
toQueryString
(
parameters
);
...
@@ -91,7 +99,9 @@ public class HttpUtil {
...
@@ -91,7 +99,9 @@ public class HttpUtil {
}
}
}
}
connection
.
connect
();
connection
.
connect
();
return
responseBody
(
connection
);
String
result
=
responseBody
(
connection
);
logger
.
debug
(
result
);
return
result
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
finally
{
}
finally
{
...
@@ -101,6 +111,9 @@ public class HttpUtil {
...
@@ -101,6 +111,9 @@ public class HttpUtil {
public
static
String
postRaw
(
String
requestUrl
,
Map
<
String
,
Object
>
parameters
,
Map
<
String
,
String
>
headers
)
{
public
static
String
postRaw
(
String
requestUrl
,
Map
<
String
,
Object
>
parameters
,
Map
<
String
,
String
>
headers
)
{
logger
.
debug
(
requestUrl
);
logger
.
debug
(
JSON
.
toJSONString
(
parameters
));
logger
.
debug
(
JSON
.
toJSONString
(
headers
));
HttpURLConnection
connection
=
null
;
HttpURLConnection
connection
=
null
;
OutputStream
os
=
null
;
OutputStream
os
=
null
;
try
{
try
{
...
@@ -120,7 +133,9 @@ public class HttpUtil {
...
@@ -120,7 +133,9 @@ public class HttpUtil {
String
rawData
=
JSON
.
toJSONString
(
parameters
);
String
rawData
=
JSON
.
toJSONString
(
parameters
);
os
.
write
(
rawData
.
getBytes
());
os
.
write
(
rawData
.
getBytes
());
os
.
flush
();
os
.
flush
();
return
responseBody
(
connection
);
String
result
=
responseBody
(
connection
);
logger
.
debug
(
result
);
return
result
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
finally
{
}
finally
{
...
...
src/main/resources/logback.xml
View file @
7815ba36
...
@@ -38,6 +38,8 @@
...
@@ -38,6 +38,8 @@
</root>
</root>
</springProfile>
</springProfile>
<logger
name=
"com.egolm.sso"
level=
"DEBUG"
/>
<logger
name=
"com.egolm.sso.config.ExceptionAspect"
level=
"ERROR"
>
<logger
name=
"com.egolm.sso.config.ExceptionAspect"
level=
"ERROR"
>
<appender-ref
ref=
"errorAppender"
/>
<appender-ref
ref=
"errorAppender"
/>
</logger>
</logger>
...
...
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