Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
ppt_server
Overview
Overview
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
Li Feifei
ppt_server
Commits
316f35e7
Commit
316f35e7
authored
Jul 26, 2021
by
Li Feifei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
format
parent
98b94a73
Pipeline
#15630
passed with stages
in 37 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
8 deletions
+10
-8
http_client.go
library/http/http_client.go
+8
-6
session_http_client.go
library/http/session_http_client.go
+2
-2
No files found.
library/http/http_client.go
View file @
316f35e7
...
...
@@ -2,7 +2,6 @@ package http
import
(
"io"
"net/http"
"os"
"time"
...
...
@@ -11,27 +10,30 @@ import (
)
func
Get
(
url
string
)
([]
byte
,
error
)
{
return
H
andle
(
g
.
Client
()
.
Timeout
(
30
*
time
.
Second
)
.
Get
(
url
))
return
h
andle
(
g
.
Client
()
.
Timeout
(
30
*
time
.
Second
)
.
Get
(
url
))
}
func
Handle
(
response
*
ghttp
.
ClientResponse
,
err
error
)
([]
byte
,
error
)
{
func
handle
(
response
*
ghttp
.
ClientResponse
,
err
error
)
([]
byte
,
error
)
{
if
err
!=
nil
{
return
nil
,
err
}
defer
response
.
Close
()
return
response
.
ReadAll
(),
nil
}
// 下载文件
func
Download
(
file
string
,
path
string
)
error
{
g
.
Log
()
.
Async
()
.
Infof
(
"Download zip url: %s "
,
file
)
resp
,
err
:=
http
.
Get
(
file
)
g
.
Log
()
.
Async
()
.
Infof
(
"Download url: %s "
,
file
)
resp
,
err
:=
g
.
Client
()
.
Get
(
file
)
if
err
!=
nil
{
return
err
}
defer
resp
.
Body
.
Close
()
// 创建一个文件用于保存
out
,
err
:=
os
.
Create
(
path
)
if
err
!=
nil
{
...
...
library/http/session_http_client.go
View file @
316f35e7
...
...
@@ -29,10 +29,10 @@ func NewSessionHttpClient() *SessionHttpClient {
}
func
(
client
*
SessionHttpClient
)
Post
(
link
string
,
data
...
interface
{})
([]
byte
,
error
)
{
return
Handle
(
client
.
c
.
Timeout
(
10
*
time
.
Second
)
.
Post
(
link
,
data
))
return
handle
(
client
.
c
.
Timeout
(
10
*
time
.
Second
)
.
Post
(
link
,
data
))
}
func
(
client
*
SessionHttpClient
)
Get
(
url
string
)
([]
byte
,
error
)
{
return
H
andle
(
client
.
c
.
Timeout
(
10
*
time
.
Second
)
.
Get
(
url
))
return
h
andle
(
client
.
c
.
Timeout
(
10
*
time
.
Second
)
.
Get
(
url
))
}
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