I'm reading the Body of an HTTP request. In my handler I want to chunk the response body up into fixed size blocks. I doing this using the following code:
b := make([]byte, config.Blocksize) for { cnt, err := r.Body.Read(b) if err == io.EOF { break } if err != nil { log.Error("Reading reading request stream", "name", name) utils.WriteError(w, http.StatusInternalServerError, "Error reading request stream") return } log.Info("Length read", "len", cnt) } What I'm seeing is various block sizes being read from the Body reader. I assume that is because the bytes coming over the http stream are not coming fast enough to keep up with my executing code, and so when r.Body.Read is executed I get how ever many bytes are currently available on the stream and not more. Is there easy way to read fixed size blocks from the request body reader using a built in library function? Say bytes, or bufio. I looked but could not see a function. I can imagine doing this myself, with multiple reads inside the for loop. Thanks Michael- -- 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. For more options, visit https://groups.google.com/d/optout.