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
a3285842
Commit
a3285842
authored
Sep 28, 2016
by
astaxie
Committed by
GitHub
Sep 28, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2193 from LyricTian/develop
httplib add CheckRedirect
parents
bba04dd8
f19ad3fd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
httplib.go
httplib/httplib.go
+14
-0
No files found.
httplib/httplib.go
View file @
a3285842
...
...
@@ -136,6 +136,7 @@ type BeegoHTTPSettings struct {
TLSClientConfig
*
tls
.
Config
Proxy
func
(
*
http
.
Request
)
(
*
url
.
URL
,
error
)
Transport
http
.
RoundTripper
CheckRedirect
func
(
req
*
http
.
Request
,
via
[]
*
http
.
Request
)
error
EnableCookie
bool
Gzip
bool
DumpBody
bool
...
...
@@ -265,6 +266,15 @@ func (b *BeegoHTTPRequest) SetProxy(proxy func(*http.Request) (*url.URL, error))
return
b
}
// SetCheckRedirect specifies the policy for handling redirects.
//
// If CheckRedirect is nil, the Client uses its default policy,
// which is to stop after 10 consecutive requests.
func
(
b
*
BeegoHTTPRequest
)
SetCheckRedirect
(
redirect
func
(
req
*
http
.
Request
,
via
[]
*
http
.
Request
)
error
)
*
BeegoHTTPRequest
{
b
.
setting
.
CheckRedirect
=
redirect
return
b
}
// Param adds query param in to request.
// params build query string as ?key1=value1&key2=value2...
func
(
b
*
BeegoHTTPRequest
)
Param
(
key
,
value
string
)
*
BeegoHTTPRequest
{
...
...
@@ -446,6 +456,10 @@ func (b *BeegoHTTPRequest) DoRequest() (*http.Response, error) {
b
.
req
.
Header
.
Set
(
"User-Agent"
,
b
.
setting
.
UserAgent
)
}
if
b
.
setting
.
CheckRedirect
!=
nil
{
client
.
CheckRedirect
=
b
.
setting
.
CheckRedirect
}
if
b
.
setting
.
ShowDebug
{
dump
,
err
:=
httputil
.
DumpRequest
(
b
.
req
,
b
.
setting
.
DumpBody
)
if
err
!=
nil
{
...
...
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