Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
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
YZG
yzg-util
Commits
0c3ce853
Commit
0c3ce853
authored
May 12, 2022
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复bug
parent
2299e56e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
15 deletions
+16
-15
HttpHelper.java
...src/main/java/com/yanzuoguang/util/helper/HttpHelper.java
+16
-15
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/HttpHelper.java
View file @
0c3ce853
...
@@ -22,11 +22,11 @@ public class HttpHelper {
...
@@ -22,11 +22,11 @@ public class HttpHelper {
/**
/**
* 链接超时
* 链接超时
*/
*/
public
static
int
HTTP_CONNECT_TIMEOUT
=
10
*
1000
;
public
static
int
HTTP_CONNECT_TIMEOUT
=
3
*
1000
;
/**
/**
* 读取超时
* 读取超时
*/
*/
public
static
int
HTTP_READ_TIMEOUT
=
30
*
1000
;
public
static
int
HTTP_READ_TIMEOUT
=
15
*
1000
;
/**
/**
* 字符编码
* 字符编码
*/
*/
...
@@ -46,7 +46,7 @@ public class HttpHelper {
...
@@ -46,7 +46,7 @@ public class HttpHelper {
* 获取请求参数
* 获取请求参数
*
*
* @param obj 对象
* @param obj 对象
* @return
* @return
请求参数字符串
*/
*/
public
static
String
getUrlParameter
(
Object
obj
,
String
charset
)
{
public
static
String
getUrlParameter
(
Object
obj
,
String
charset
)
{
MapRow
to
=
JsonHelper
.
to
(
obj
,
MapRow
.
class
);
MapRow
to
=
JsonHelper
.
to
(
obj
,
MapRow
.
class
);
...
@@ -66,8 +66,8 @@ public class HttpHelper {
...
@@ -66,8 +66,8 @@ public class HttpHelper {
* 获取连接
* 获取连接
*
*
* @param url 请求地址
* @param url 请求地址
* @return
* @return
链接
* @throws IOException
* @throws IOException
抛出的异常信息
*/
*/
public
static
HttpURLConnection
getConn
(
String
url
)
throws
IOException
{
public
static
HttpURLConnection
getConn
(
String
url
)
throws
IOException
{
return
getConn
(
url
,
null
,
false
);
return
getConn
(
url
,
null
,
false
);
...
@@ -78,8 +78,8 @@ public class HttpHelper {
...
@@ -78,8 +78,8 @@ public class HttpHelper {
*
*
* @param url 请求地址
* @param url 请求地址
* @param header 请求头
* @param header 请求头
* @return
* @return
链接
* @throws IOException
* @throws IOException
抛出的异常信息
*/
*/
public
static
HttpURLConnection
getConn
(
String
url
,
Map
<
String
,
String
>
header
)
throws
IOException
{
public
static
HttpURLConnection
getConn
(
String
url
,
Map
<
String
,
String
>
header
)
throws
IOException
{
return
getConn
(
url
,
header
,
false
);
return
getConn
(
url
,
header
,
false
);
...
@@ -90,8 +90,8 @@ public class HttpHelper {
...
@@ -90,8 +90,8 @@ public class HttpHelper {
*
*
* @param url 请求地址
* @param url 请求地址
* @param isApplicationJson 是否请求json
* @param isApplicationJson 是否请求json
* @return
* @return
链接
* @throws IOException
* @throws IOException
抛出的异常信息
*/
*/
public
static
HttpURLConnection
getConn
(
String
url
,
boolean
isApplicationJson
)
throws
IOException
{
public
static
HttpURLConnection
getConn
(
String
url
,
boolean
isApplicationJson
)
throws
IOException
{
return
getConn
(
url
,
null
,
isApplicationJson
);
return
getConn
(
url
,
null
,
isApplicationJson
);
...
@@ -103,8 +103,8 @@ public class HttpHelper {
...
@@ -103,8 +103,8 @@ public class HttpHelper {
* @param url 请求地址
* @param url 请求地址
* @param header 请求头
* @param header 请求头
* @param isApplicationJson 是否请求json
* @param isApplicationJson 是否请求json
* @return
* @return
链接
* @throws IOException
* @throws IOException
抛出的异常信息
*/
*/
public
static
HttpURLConnection
getConn
(
String
url
,
Map
<
String
,
String
>
header
,
boolean
isApplicationJson
)
throws
IOException
{
public
static
HttpURLConnection
getConn
(
String
url
,
Map
<
String
,
String
>
header
,
boolean
isApplicationJson
)
throws
IOException
{
// 创建URL对象
// 创建URL对象
...
@@ -289,10 +289,11 @@ public class HttpHelper {
...
@@ -289,10 +289,11 @@ public class HttpHelper {
/**
/**
* 读取数据流
* 读取数据流
*
*
* @param stream
* @param stream 流
* @param result
* @param result 结果字符串
* @return
* @param charset 编码方式
* @throws IOException
* @return 读取的缓存流
* @throws IOException IO异常
*/
*/
private
static
BufferedReader
readStream
(
InputStream
stream
,
StringBuilder
result
,
String
charset
)
throws
IOException
{
private
static
BufferedReader
readStream
(
InputStream
stream
,
StringBuilder
result
,
String
charset
)
throws
IOException
{
if
(
stream
==
null
)
{
if
(
stream
==
null
)
{
...
...
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