Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
d90ce157
authored
2015-04-08 21:45:00 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
httplib support gzip
1 parent
23457ed2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
httplib/httplib.go
httplib/httplib.go
View file @
d90ce15
...
...
@@ -32,6 +32,7 @@ package httplib
import
(
"bytes"
"compress/gzip"
"crypto/tls"
"encoding/json"
"encoding/xml"
...
...
@@ -50,7 +51,7 @@ import (
"time"
)
var
defaultSetting
=
BeegoHttpSettings
{
false
,
"beegoServer"
,
60
*
time
.
Second
,
60
*
time
.
Second
,
nil
,
nil
,
nil
,
false
}
var
defaultSetting
=
BeegoHttpSettings
{
false
,
"beegoServer"
,
60
*
time
.
Second
,
60
*
time
.
Second
,
nil
,
nil
,
nil
,
false
,
true
}
var
defaultCookieJar
http
.
CookieJar
var
settingMutex
sync
.
Mutex
...
...
@@ -122,6 +123,7 @@ type BeegoHttpSettings struct {
Proxy
func
(
*
http
.
Request
)
(
*
url
.
URL
,
error
)
Transport
http
.
RoundTripper
EnableCookie
bool
Gzip
bool
}
// BeegoHttpRequest provides more useful methods for requesting one url than http.Request.
...
...
@@ -434,7 +436,15 @@ func (b *BeegoHttpRequest) Bytes() ([]byte, error) {
return
nil
,
nil
}
defer
resp
.
Body
.
Close
()
b
.
body
,
err
=
ioutil
.
ReadAll
(
resp
.
Body
)
if
b
.
setting
.
Gzip
&&
resp
.
Header
.
Get
(
"Content-Encoding"
)
==
"gzip"
{
reader
,
err
:=
gzip
.
NewReader
(
resp
.
Body
)
if
err
!=
nil
{
return
nil
,
err
}
b
.
body
,
err
=
ioutil
.
ReadAll
(
reader
)
}
else
{
b
.
body
,
err
=
ioutil
.
ReadAll
(
resp
.
Body
)
}
if
err
!=
nil
{
return
nil
,
err
}
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment