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
98c23077
authored
2014-08-22 22:02:40 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #767 from JessonChan/develop
bug fixed
2 parents
35b4022e
485c2e86
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
46 deletions
httplib/httplib.go
httplib/httplib.go
View file @
98c2307
...
...
@@ -73,64 +73,42 @@ func SetDefaultSetting(setting BeegoHttpSettings) {
}
}
// Get returns *BeegoHttpRequest with GET method.
func
Get
(
url
string
)
*
BeegoHttpRequest
{
var
req
http
.
Request
// return *BeegoHttpRequest with specific method
func
newBeegoRequest
(
url
,
method
string
)
*
BeegoHttpRequest
{
req
:=
http
.
Request
{
Proto
:
"HTTP/1.1"
,
ProtoMajor
:
1
,
ProtoMinor
:
1
,
}
var
resp
http
.
Response
req
.
Method
=
"GET"
req
.
Method
=
method
req
.
Header
=
http
.
Header
{}
req
.
Proto
=
"HTTP/1.1"
req
.
ProtoMajor
=
1
req
.
ProtoMinor
=
1
return
&
BeegoHttpRequest
{
url
,
&
req
,
map
[
string
]
string
{},
map
[
string
]
string
{},
defaultSetting
,
&
resp
,
nil
}
}
// Get returns *BeegoHttpRequest with GET method.
func
Get
(
url
string
)
*
BeegoHttpRequest
{
return
newBeegoRequest
(
url
,
"GET"
)
}
// Post returns *BeegoHttpRequest with POST method.
func
Post
(
url
string
)
*
BeegoHttpRequest
{
var
req
http
.
Request
var
resp
http
.
Response
req
.
Method
=
"POST"
req
.
Header
=
http
.
Header
{}
req
.
Proto
=
"HTTP/1.1"
req
.
ProtoMajor
=
1
req
.
ProtoMinor
=
1
return
&
BeegoHttpRequest
{
url
,
&
req
,
map
[
string
]
string
{},
map
[
string
]
string
{},
defaultSetting
,
&
resp
,
nil
}
return
newBeegoRequest
(
url
,
"POST"
)
}
// Put returns *BeegoHttpRequest with PUT method.
func
Put
(
url
string
)
*
BeegoHttpRequest
{
var
req
http
.
Request
var
resp
http
.
Response
req
.
Method
=
"PUT"
req
.
Header
=
http
.
Header
{}
req
.
Proto
=
"HTTP/1.1"
req
.
ProtoMajor
=
1
req
.
ProtoMinor
=
1
return
&
BeegoHttpRequest
{
url
,
&
req
,
map
[
string
]
string
{},
map
[
string
]
string
{},
defaultSetting
,
&
resp
,
nil
}
return
newBeegoRequest
(
url
,
"PUT"
)
}
// Delete returns *BeegoHttpRequest DELETE GET method.
func
Delete
(
url
string
)
*
BeegoHttpRequest
{
var
req
http
.
Request
var
resp
http
.
Response
req
.
Method
=
"DELETE"
req
.
Header
=
http
.
Header
{}
req
.
Proto
=
"HTTP/1.1"
req
.
ProtoMajor
=
1
req
.
ProtoMinor
=
1
return
&
BeegoHttpRequest
{
url
,
&
req
,
map
[
string
]
string
{},
map
[
string
]
string
{},
defaultSetting
,
&
resp
,
nil
}
return
newBeegoRequest
(
url
,
"DELETE"
)
}
// Head returns *BeegoHttpRequest with HEAD method.
func
Head
(
url
string
)
*
BeegoHttpRequest
{
var
req
http
.
Request
var
resp
http
.
Response
req
.
Method
=
"HEAD"
req
.
Header
=
http
.
Header
{}
req
.
Proto
=
"HTTP/1.1"
req
.
ProtoMajor
=
1
req
.
ProtoMinor
=
1
return
&
BeegoHttpRequest
{
url
,
&
req
,
map
[
string
]
string
{},
map
[
string
]
string
{},
defaultSetting
,
&
resp
,
nil
}
return
newBeegoRequest
(
url
,
"HEAD"
)
}
// BeegoHttpSettings
...
...
@@ -341,13 +319,6 @@ func (b *BeegoHttpRequest) getResponse() (*http.Response, error) {
}
b
.
req
.
URL
=
url
if
b
.
setting
.
ShowDebug
{
dump
,
err
:=
httputil
.
DumpRequest
(
b
.
req
,
true
)
if
err
!=
nil
{
println
(
err
.
Error
())
}
println
(
string
(
dump
))
}
trans
:=
b
.
setting
.
Transport
...
...
@@ -392,6 +363,14 @@ func (b *BeegoHttpRequest) getResponse() (*http.Response, error) {
b
.
req
.
Header
.
Set
(
"User-Agent"
,
b
.
setting
.
UserAgent
)
}
if
b
.
setting
.
ShowDebug
{
dump
,
err
:=
httputil
.
DumpRequest
(
b
.
req
,
true
)
if
err
!=
nil
{
println
(
err
.
Error
())
}
println
(
string
(
dump
))
}
resp
,
err
:=
client
.
Do
(
b
.
req
)
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