Description
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version
)?
go version go1.10.1 linux/amd64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env
)?
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/qhyu/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/qhyu/git/go"
GORACE=""
GOROOT="/home/qhyu/work/installed/go"
GOTMPDIR=""
GOTOOLDIR="/home/qhyu/work/installed/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build281947105=/tmp/go-build -gno-record-gcc-switches"
What did you do?
use go http client to post a request to the go server use chunked protocol,the data send speed is constant
below is the client test code .
go func() {
buf := make([]byte, 640)
f, _ := os.Open(casefile)
for {
n, _ := f.Read(buf)
if 0 == n {
break
}
wr.Write(buf)
// fmt.Println("write buf,sleep 20 ms")
time.Sleep(time.Millisecond * 20)
}
tch <- time.Now()
// fmt.Println("send tch complete")
wr.Close()
}()
req := &http.Request{
Method: "POST",
ProtoMajor: 1,
ProtoMinor: 1,
URL: u,
TransferEncoding: []string{"chunked"},
Body: rd,
Header: make(map[string][]string),
}
req.Header.Set("Content-Type", fmt.Sprintf("audio/%s;bit=16;rate=16000", tlvtype))
queryparam := req.URL.Query()
queryparam.Add("deviceId", "12348343948394343434898")
queryparam.Add("lang", "zh")
traceid := GetTraceId(16)
queryparam.Add("traceId", traceid)
req.URL.RawQuery = queryparam.Encode()
client := http.DefaultClient
resp, err := client.Do(req)
if nil != err {
fmt.Println("error =>", err.Error())
return
}
body, err := ioutil.ReadAll(resp.Body)
fmt.Printf("traceid: %s\tserver time: %s\talltime: %s\n", traceid, retm, alltime)
if err == nil {
resp.Body.Close()
}
What did you expect to see?
when an error occur because of parameters check etc. the response will immediately get .
What did you see instead?
When the server validator fails, because of none request data was consumption, this should return an error code to the client directly, but now as a result, the client will wait for a long period of time (reading maxPostHandlerReadBytes bytes to flush response) to get the error code