Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
pdstask
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
曲欣亮
pdstask
Commits
4cee6888
Commit
4cee6888
authored
Jul 16, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
1d9e20f7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
28 deletions
+2
-28
HttpUtil.java
src/main/java/com/egolm/pds/config/HttpUtil.java
+2
-28
No files found.
src/main/java/com/egolm/pds/config/HttpUtil.java
View file @
4cee6888
...
@@ -77,11 +77,6 @@ public class HttpUtil {
...
@@ -77,11 +77,6 @@ public class HttpUtil {
}
}
public
static
String
post
(
String
requestUrl
,
Map
<
String
,
String
>
parameters
,
Map
<
String
,
String
>
headers
)
{
public
static
String
post
(
String
requestUrl
,
Map
<
String
,
String
>
parameters
,
Map
<
String
,
String
>
headers
)
{
return
post
(
requestUrl
,
parameters
,
headers
,
null
);
}
public
static
String
post
(
String
requestUrl
,
Map
<
String
,
String
>
parameters
,
Map
<
String
,
String
>
headers
,
Map
<
String
,
File
>
attachments
)
{
HttpURLConnection
connection
=
null
;
HttpURLConnection
connection
=
null
;
try
{
try
{
Data
data
=
new
Data
();
Data
data
=
new
Data
();
...
@@ -95,26 +90,9 @@ public class HttpUtil {
...
@@ -95,26 +90,9 @@ public class HttpUtil {
ParamBuffer
.
append
(
parameters
.
get
(
key
)
+
"\r\n"
);
ParamBuffer
.
append
(
parameters
.
get
(
key
)
+
"\r\n"
);
}
}
}
}
ParamBuffer
.
append
(
"--"
+
BOUNDARY
ParamBuffer
.
append
(
"--"
+
BOUNDARY
+
"\r\nContent-Disposition: form-data; name=\"----------------------------------\"\r\n\r\n-------------------------\r\n"
);
+
"\r\nContent-Disposition: form-data; name=\"----------------------------------\"\r\n\r\n-------------------------\r\n"
);
String
ParamBufferString
=
ParamBuffer
.
toString
();
String
ParamBufferString
=
ParamBuffer
.
toString
();
data
.
add
(
ParamBufferString
.
getBytes
());
data
.
add
(
ParamBufferString
.
getBytes
());
if
(
attachments
!=
null
)
{
for
(
String
name
:
attachments
.
keySet
())
{
StringBuffer
FileBuffer
=
new
StringBuffer
();
File
file
=
attachments
.
get
(
name
);
FileBuffer
.
append
(
"--"
+
BOUNDARY
+
"\r\n"
);
FileBuffer
.
append
(
"Content-Disposition: form-data; name=\""
+
name
+
"\"; filename=\""
+
file
.
getName
()
+
"\""
+
"\r\n"
);
FileBuffer
.
append
(
"Content-Type: application/octet-stream"
+
"\r\n"
);
FileBuffer
.
append
(
"\r\n"
);
String
FileBufferString
=
FileBuffer
.
toString
();
data
.
add
(
FileBufferString
.
getBytes
());
data
.
add
(
file
);
String
FileEnd
=
"\r\n"
;
data
.
add
(
FileEnd
.
getBytes
());
}
}
StringBuffer
EndBuffer
=
new
StringBuffer
(
"\r\n--"
+
BOUNDARY
+
"--\r\n"
);
StringBuffer
EndBuffer
=
new
StringBuffer
(
"\r\n--"
+
BOUNDARY
+
"--\r\n"
);
String
EndBufferString
=
EndBuffer
.
toString
();
String
EndBufferString
=
EndBuffer
.
toString
();
data
.
add
(
EndBufferString
.
getBytes
());
data
.
add
(
EndBufferString
.
getBytes
());
...
@@ -122,7 +100,7 @@ public class HttpUtil {
...
@@ -122,7 +100,7 @@ public class HttpUtil {
connection
=
(
HttpURLConnection
)
url
.
openConnection
();
connection
=
(
HttpURLConnection
)
url
.
openConnection
();
connection
.
setRequestMethod
(
"POST"
);
connection
.
setRequestMethod
(
"POST"
);
connection
.
setRequestProperty
(
"Accept-Charset"
,
"utf-8"
);
connection
.
setRequestProperty
(
"Accept-Charset"
,
"utf-8"
);
connection
.
setRequestProperty
(
"Content-Type"
,
"
multipart/form-data
; boundary="
+
BOUNDARY
);
connection
.
setRequestProperty
(
"Content-Type"
,
"
application/json
; boundary="
+
BOUNDARY
);
connection
.
setRequestProperty
(
"Content-Length"
,
String
.
valueOf
(
data
.
length
()));
connection
.
setRequestProperty
(
"Content-Length"
,
String
.
valueOf
(
data
.
length
()));
if
(
headers
!=
null
)
{
if
(
headers
!=
null
)
{
for
(
String
key
:
headers
.
keySet
())
{
for
(
String
key
:
headers
.
keySet
())
{
...
@@ -137,10 +115,6 @@ public class HttpUtil {
...
@@ -137,10 +115,6 @@ public class HttpUtil {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
finally
{
if
(
connection
!=
null
)
{
connection
.
disconnect
();
}
}
}
}
}
...
...
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