Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
d90ce157
Commit
d90ce157
authored
Apr 08, 2015
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
httplib support gzip
parent
23457ed2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
httplib.go
httplib/httplib.go
+12
-2
No files found.
httplib/httplib.go
View file @
d90ce157
...
...
@@ -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
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