summaryrefslogtreecommitdiffhomepage
path: root/src/go/unit/request.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/go/unit/request.go')
-rw-r--r--src/go/unit/request.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/go/unit/request.go b/src/go/unit/request.go
index 3d313ce2..7d99edaa 100644
--- a/src/go/unit/request.go
+++ b/src/go/unit/request.go
@@ -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
}