summaryrefslogtreecommitdiffhomepage
path: root/src/go/unit
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2018-04-20 17:23:43 +0300
committerMax Romanov <max.romanov@nginx.com>2018-04-20 17:23:43 +0300
commitad36c8ca8da62d3c19398bf04aceb0f113cc253d (patch)
tree571f9b154a5f3bf1f2aab882bc75ef421b6515a3 /src/go/unit
parenta20830ff554a10094894e825ef9124c4a81745b6 (diff)
downloadunit-ad36c8ca8da62d3c19398bf04aceb0f113cc253d.tar.gz
unit-ad36c8ca8da62d3c19398bf04aceb0f113cc253d.tar.bz2
Go: fixed request.Read() behaviour for EOF.
This closes #108 issue on GitHub.
Diffstat (limited to 'src/go/unit')
-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
}