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
51161361
authored
2015-04-26 15:42:10 +0800
by
JessonChan
Committed by
astaxie
2015-05-25 09:10:37 +0800
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
more fixed
1 parent
6da0cdb9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
httplib/httplib.go
httplib/httplib.go
View file @
5116136
...
...
@@ -36,6 +36,7 @@ import (
"crypto/tls"
"encoding/json"
"encoding/xml"
"fmt"
"io"
"io/ioutil"
"log"
...
...
@@ -278,12 +279,15 @@ func (b *BeegoHttpRequest) JsonBody(obj interface{}) (*BeegoHttpRequest, error)
}
func
(
b
*
BeegoHttpRequest
)
buildUrl
(
paramBody
string
)
{
if
paramBody
==
""
{
return
}
// build GET url with query string
if
b
.
req
.
Method
==
"GET"
&&
len
(
paramBody
)
>
0
{
if
strings
.
Index
(
b
.
url
,
"?"
)
!=
-
1
{
b
.
url
+=
"&"
+
paramBody
}
else
{
if
b
.
req
.
Method
==
"GET"
{
if
strings
.
Index
(
b
.
url
,
"?"
)
==
-
1
{
b
.
url
=
b
.
url
+
"?"
+
paramBody
}
else
{
b
.
url
+=
"&"
+
paramBody
}
return
}
...
...
@@ -336,18 +340,14 @@ func (b *BeegoHttpRequest) getResponse() (*http.Response, error) {
}
var
paramBody
string
if
len
(
b
.
params
)
>
0
{
var
buf
bytes
.
Buffer
for
k
,
v
:=
range
b
.
params
{
buf
.
WriteString
(
url
.
QueryEscape
(
k
))
buf
.
WriteByte
(
'='
)
buf
.
WriteString
(
url
.
QueryEscape
(
v
))
buf
.
WriteByte
(
'&'
)
paramBody
+=
fmt
.
Sprintf
(
"&%s=%v"
,
url
.
QueryEscape
(
k
),
url
.
QueryEscape
(
v
))
}
paramBody
=
buf
.
String
()
paramBody
=
paramBody
[
0
:
len
(
paramBody
)
-
1
]
paramBody
=
paramBody
[
1
:
]
}
b
.
buildUrl
(
paramBody
)
url
,
err
:=
url
.
Parse
(
b
.
url
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -399,7 +399,7 @@ func (b *BeegoHttpRequest) getResponse() (*http.Response, error) {
if
b
.
setting
.
ShowDebug
{
dump
,
err
:=
httputil
.
DumpRequest
(
b
.
req
,
true
)
if
err
!=
nil
{
p
rintln
(
err
.
Error
())
log
.
P
rintln
(
err
.
Error
())
}
b
.
dump
=
dump
}
...
...
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