Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
im-common
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
陈永峰
im-common
Commits
23320c4a
Commit
23320c4a
authored
Jul 29, 2021
by
YXxy1002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: IDEA warnings
parent
c4e6a6a8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
13 deletions
+14
-13
HttpUtil.java
src/main/java/com/qcloud/im/util/HttpUtil.java
+14
-13
No files found.
src/main/java/com/qcloud/im/util/HttpUtil.java
View file @
23320c4a
...
@@ -5,6 +5,7 @@ import java.net.HttpURLConnection;
...
@@ -5,6 +5,7 @@ import java.net.HttpURLConnection;
import
java.net.URL
;
import
java.net.URL
;
import
java.net.URLDecoder
;
import
java.net.URLDecoder
;
import
java.net.URLEncoder
;
import
java.net.URLEncoder
;
import
java.nio.charset.StandardCharsets
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -110,22 +111,22 @@ public class HttpUtil {
...
@@ -110,22 +111,22 @@ public class HttpUtil {
headers
.
put
(
"Content-Type"
,
"application/x-www-form-urlencoded"
);
headers
.
put
(
"Content-Type"
,
"application/x-www-form-urlencoded"
);
// parse parameters
// parse parameters
String
body
=
""
;
String
Builder
body
=
new
StringBuilder
()
;
if
(
params
!=
null
)
{
if
(
params
!=
null
)
{
boolean
first
=
true
;
boolean
first
=
true
;
for
(
String
param
:
params
.
keySet
())
{
for
(
String
param
:
params
.
keySet
())
{
if
(
first
)
{
if
(
first
)
{
first
=
false
;
first
=
false
;
}
else
{
}
else
{
body
+=
"&"
;
body
.
append
(
"&"
)
;
}
}
String
value
=
params
.
get
(
param
);
String
value
=
params
.
get
(
param
);
body
+=
URLEncoder
.
encode
(
param
,
"UTF-8"
)
+
"="
;
body
.
append
(
URLEncoder
.
encode
(
param
,
"UTF-8"
)).
append
(
"="
)
;
body
+=
URLEncoder
.
encode
(
value
,
"UTF-8"
);
body
.
append
(
URLEncoder
.
encode
(
value
,
"UTF-8"
)
);
}
}
}
}
return
post
(
url
,
body
,
headers
);
return
post
(
url
,
body
.
toString
()
,
headers
);
}
}
/**
/**
...
@@ -187,23 +188,23 @@ public class HttpUtil {
...
@@ -187,23 +188,23 @@ public class HttpUtil {
*/
*/
public
static
String
appendQueryParams
(
String
url
,
public
static
String
appendQueryParams
(
String
url
,
Map
<
String
,
String
>
params
)
throws
IOException
{
Map
<
String
,
String
>
params
)
throws
IOException
{
String
fullUrl
=
url
;
String
Builder
fullUrl
=
new
StringBuilder
(
url
)
;
if
(
params
!=
null
)
{
if
(
params
!=
null
)
{
boolean
first
=
(
fullUrl
.
indexOf
(
'?'
)
==
-
1
);
boolean
first
=
(
fullUrl
.
toString
().
indexOf
(
'?'
)
==
-
1
);
for
(
String
param
:
params
.
keySet
())
{
for
(
String
param
:
params
.
keySet
())
{
if
(
first
)
{
if
(
first
)
{
fullUrl
+=
'?'
;
fullUrl
.
append
(
'?'
)
;
first
=
false
;
first
=
false
;
}
else
{
}
else
{
fullUrl
+=
'&'
;
fullUrl
.
append
(
'&'
)
;
}
}
String
value
=
params
.
get
(
param
);
String
value
=
params
.
get
(
param
);
fullUrl
+=
URLEncoder
.
encode
(
param
,
"UTF-8"
)
+
'='
;
fullUrl
.
append
(
URLEncoder
.
encode
(
param
,
"UTF-8"
)).
append
(
'='
)
;
fullUrl
+=
URLEncoder
.
encode
(
value
,
"UTF-8"
);
fullUrl
.
append
(
URLEncoder
.
encode
(
value
,
"UTF-8"
)
);
}
}
}
}
return
fullUrl
;
return
fullUrl
.
toString
()
;
}
}
/**
/**
...
@@ -323,7 +324,7 @@ public class HttpUtil {
...
@@ -323,7 +324,7 @@ public class HttpUtil {
* @throws IOException
* @throws IOException
*/
*/
public
static
String
streamToString
(
InputStream
in
)
throws
IOException
{
public
static
String
streamToString
(
InputStream
in
)
throws
IOException
{
InputStreamReader
isr
=
new
InputStreamReader
(
in
,
"UTF-8"
);
InputStreamReader
isr
=
new
InputStreamReader
(
in
,
StandardCharsets
.
UTF_8
);
BufferedReader
br
=
new
BufferedReader
(
isr
);
BufferedReader
br
=
new
BufferedReader
(
isr
);
String
data
;
String
data
;
...
...
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