why is golang http server failing with "broken pipe" when response exceeds 8kb? : <p>I have a example web server below where if you call <code>curl localhost:3000 -v</code> then <code>^C</code> (cancel) it immediately (before 1 second), it will report <code>write tcp 127.0.0.1:3000-&gt;127.0.0.1:XXXXX: write: broken pipe</code>.</p>

<pre><code>package main

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

func main() {
    log.Fatal(http.ListenAndServe(":3000", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
            time.Sleep(1 * time.Second)

            // Why 8061 bytes? Because the response header on my computer
            // is 132 bytes, adding up the entire response to 8193 (1 byte 
            // over 8kb)
            if _, err := w.Write(make([]byte, 8061)); err != nil {
                    fmt.Println(err)
                    return
            }   
    })))
}
</code></pre>

<p>Based on my debugging, I have been able to conclude that this will only happen if the entire response is writing more than 8192 bytes (or 8kb). If my entire response write less than 8192, the <code>broken pipe</code> error is not returned.</p>

<p>My question is <strong>where is this 8192 bytes (or 8kb) buffer limit set?</strong> Is this a limit in Golang's HTTP write buffer? Is this related to the response being chunked? Is this only related to the <code>curl</code> client or the browser client? How can I change this limit so I can have a bigger buffer written before the connection is closed (for debugging purposes)?</p>

<p>Thanks!</p>
