Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: receiving binary post-data in handler (server) #5560

Closed
gopherbot opened this issue May 25, 2013 · 3 comments
Closed

net/http: receiving binary post-data in handler (server) #5560

gopherbot opened this issue May 25, 2013 · 3 comments

Comments

@gopherbot
Copy link

by cgmurray:

What steps will reproduce the problem?

Run the following server app with "go run":
package main

import (
    "fmt"
    "io"
    "net/http"
)

type handler struct{}

func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
    r.Header.Set("Content-Type", "application/octet-stream")
    io.Copy(w, r.Body)
}

func main() {
    port := 9090
    http.ListenAndServe(fmt.Sprintf(":%d", port), new(handler))
}

create a text-file, "two_lines", with the following content:
one
two

post the text-file using curl:
curl -X POST -d@two_lines  --header "Content-Type: application/octet-stream"
http://localhost:9090

What is the expected output?
one
two

What do you see instead?
onetwo

Which operating system are you using?
OS X 10.8.3

Which version are you using?  (run 'go version')
go version go1.1 darwin/amd64
@remyoudompheng
Copy link
Contributor

Comment 1:

I think you are misusing curl. You should be using --data-binary, not -d.
Please confirm.

Status changed to WaitingForReply.

@gopherbot
Copy link
Author

Comment 2 by cgmurray:

Sorry for the invalid bug-report. It works with --data-binary.
The background is that I can't get git-http-backend to work with go/http. The issue is
probably related to something else.

@minux
Copy link
Member

minux commented May 25, 2013

Comment 3:

Status changed to Retracted.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants