You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/12/27 02:45:23 UTC

[GitHub] [apisix-go-plugin-runner] An-DJ commented on a diff in pull request #124: fix(#114): fix transfering large body failed

An-DJ commented on code in PR #124:
URL: https://github.com/apache/apisix-go-plugin-runner/pull/124#discussion_r1057409696


##########
internal/util/msg.go:
##########
@@ -65,3 +66,27 @@ func WriteErr(n int, err error) {
 		log.Errorf("write: %s", err)
 	}
 }
+
+func ReadBytes(c net.Conn, b []byte, n int) (int, error) {
+	l := 0
+	for l < n {
+		tmp, err := c.Read(b[l:])
+		if err != nil {
+			return l, err

Review Comment:
   The data in `b[l: l + tmp]` may be unreliable because the reading errror.



##########
internal/util/msg.go:
##########
@@ -65,3 +66,27 @@ func WriteErr(n int, err error) {
 		log.Errorf("write: %s", err)
 	}
 }
+
+func ReadBytes(c net.Conn, b []byte, n int) (int, error) {
+	l := 0
+	for l < n {
+		tmp, err := c.Read(b[l:])
+		if err != nil {
+			return l, err
+		}
+		l += tmp
+	}
+	return l, nil
+}
+
+func WriteBytes(c net.Conn, b []byte, n int) (int, error) {
+	l := 0
+	for l < n {
+		tmp, err := c.Write(b[l:])
+		if err != nil {
+			return l, err

Review Comment:
   Ditto



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org