Go: fixed request.Read() behaviour for EOF.

This closes #108 issue on GitHub.
This commit is contained in:
Max Romanov
2018-04-20 17:23:43 +03:00
parent a20830ff55
commit ad36c8ca8d

View File

@@ -11,6 +11,7 @@ package unit
import "C"
import (
"io"
"net/http"
"net/url"
"unsafe"
@@ -24,11 +25,15 @@ type request struct {
}
func (r *request) Read(p []byte) (n int, err error) {
c := C.size_t(cap(p))
c := C.size_t(len(p))
b := C.uintptr_t(uintptr(unsafe.Pointer(&p[0])))
res := C.nxt_go_request_read(r.c_req, b, c)
if res == 0 && len(p) > 0 {
return 0, io.EOF
}
return int(res), nil
}