Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3-cmds
Commits
7bf0670f
Commit
7bf0670f
authored
Nov 04, 2014
by
Matt Bell
Committed by
Juan Batiz-Benet
Nov 04, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands/http: Renamed variable for clarity
parent
7ef3535a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
http/client.go
http/client.go
+6
-6
No files found.
http/client.go
View file @
7bf0670f
...
...
@@ -41,7 +41,7 @@ func (c *client) Send(req cmds.Request) (cmds.Response, error) {
req
.
SetOption
(
cmds
.
EncLong
,
cmds
.
JSON
)
}
query
,
in
,
err
:=
getQuery
(
req
)
query
,
in
putStream
,
err
:=
getQuery
(
req
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -49,7 +49,7 @@ func (c *client) Send(req cmds.Request) (cmds.Response, error) {
path
:=
strings
.
Join
(
req
.
Path
(),
"/"
)
url
:=
fmt
.
Sprintf
(
ApiUrlFormat
,
c
.
serverAddress
,
ApiPath
,
path
,
query
)
httpRes
,
err
:=
http
.
Post
(
url
,
"application/octet-stream"
,
in
)
httpRes
,
err
:=
http
.
Post
(
url
,
"application/octet-stream"
,
in
putStream
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -69,7 +69,7 @@ func (c *client) Send(req cmds.Request) (cmds.Response, error) {
func
getQuery
(
req
cmds
.
Request
)
(
string
,
io
.
Reader
,
error
)
{
// TODO: handle multiple files with multipart
var
in
io
.
Reader
var
in
putStream
io
.
Reader
query
:=
url
.
Values
{}
for
k
,
v
:=
range
req
.
Options
()
{
...
...
@@ -90,14 +90,14 @@ func getQuery(req cmds.Request) (string, io.Reader, error) {
}
else
{
// TODO: multipart
if
in
!=
nil
{
if
in
putStream
!=
nil
{
return
""
,
nil
,
fmt
.
Errorf
(
"Currently, only one file stream is possible per request"
)
}
in
=
arg
.
(
io
.
Reader
)
in
putStream
=
arg
.
(
io
.
Reader
)
}
}
return
query
.
Encode
(),
in
,
nil
return
query
.
Encode
(),
in
putStream
,
nil
}
// getResponse decodes a http.Response to create a cmds.Response
...
...
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