```

// Body is the request's body.
//
// For client requests, a nil body means the request has no
// body, such as a GET request. The HTTP Client's Transport
// is responsible for calling the Close method.
//
// For server requests, the Request Body is always non-nil
// but will return EOF immediately when no body is present.
// The Server will close the request body. The ServeHTTP
// Handler does not need to.
//
// Body must allow Read to be called concurrently with Close.
// In particular, calling Close should unblock a Read waiting
// for input.
Body io.ReadCloser

```

According to the document of http.Request, the Body *must allow Read to be 
called concurrently with Close. In particular, calling Close should unblock 
a Read waiting for input.*

I would like to use the return value of os.Open() directly as the Body of 
a http.Request like this:

```

file, _ := os.Open("example.md")
http.DefaultClient.Do(&http.Request{
Body: file,
})

```

Is that appropriate? Does os.File meet the requirement "*must allow Read to 
be called concurrently with Close. In particular, calling Close should 
unblock a Read waiting for input*"?

I'd appreciate it if someone could help me out!

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/a3641e96-299c-4d7c-85f6-f45f7082cbben%40googlegroups.com.

Reply via email to