Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Go Httpbin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Container registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Nix
Go Httpbin
Commits
0df6719e
Commit
0df6719e
authored
7 years ago
by
Will McCutchen
Browse files
Options
Downloads
Patches
Plain Diff
Make sure request data is a JSON string instead of a []byte
parent
70bd01d6
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
httpbin/handlers_test.go
+3
-1
3 additions, 1 deletion
httpbin/handlers_test.go
httpbin/helpers.go
+1
-1
1 addition, 1 deletion
httpbin/helpers.go
httpbin/httpbin.go
+1
-1
1 addition, 1 deletion
httpbin/httpbin.go
with
5 additions
and
3 deletions
httpbin/handlers_test.go
+
3
−
1
View file @
0df6719e
...
...
@@ -502,7 +502,9 @@ func TestPost__JSON(t *testing.T) {
t
.
Fatalf
(
"failed to unmarshal body %s from JSON: %s"
,
w
.
Body
,
err
)
}
assertBytesEqual
(
t
,
resp
.
Data
,
inputBody
)
if
resp
.
Data
!=
string
(
inputBody
)
{
t
.
Fatalf
(
"expected data == %#v, got %#v"
,
string
(
inputBody
),
resp
.
Data
)
}
if
len
(
resp
.
Args
)
>
0
{
t
.
Fatalf
(
"expected no query params, got %#v"
,
resp
.
Args
)
}
...
...
This diff is collapsed.
Click to expand it.
httpbin/helpers.go
+
1
−
1
View file @
0df6719e
...
...
@@ -87,7 +87,7 @@ func parseBody(w http.ResponseWriter, r *http.Request, resp *bodyResponse) error
r
.
Body
.
Close
()
return
err
}
resp
.
Data
=
body
resp
.
Data
=
string
(
body
)
// After reading the body to populate resp.Data, we need to re-wrap it in
// an io.Reader for further processing below
...
...
This diff is collapsed.
Click to expand it.
httpbin/httpbin.go
+
1
−
1
View file @
0df6719e
...
...
@@ -41,7 +41,7 @@ type bodyResponse struct {
Origin
string
`json:"origin"`
URL
string
`json:"url"`
Data
[]
byte
`json:"data"`
Data
string
`json:"data"`
Files
map
[
string
][]
string
`json:"files"`
Form
map
[
string
][]
string
`json:"form"`
JSON
interface
{}
`json:"json"`
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment