Go socket read method, buffer has 1024 bytes, but only 108 bytes have been read, but obviously it is not finished yet?

  golang, question

oclipboard.png

Write a proxy tool to handle requests
TmpStr is followed by an A character, and the http Header has not been read completely.
Is there any limit to go’s socket’s read method?
I went to read again and made a mistake: EOF
Now paste the code:
main.go

package main
 
 import (
 "fmt"
 "log"
 "net"
 salamanderHttp "github.com/SalamanderHttpProxy/http"
 )
 
 func main() {
 listener, err := net.Listen("tcp", ":8080")
 if err !  = nil {
 log.Panic(err)
 }
 for {
 client, err := listener.Accept()
 if err !  = nil {
 log.Panic(err)
 }
 go salamanderHttp.HandleClientRequest(client)
 }
 }

Request.go

package http
 
 import (
 "log"
 "net"
 "strings"
 "fmt"
 )
 
 const (
 BufferSize = 1024
 LF         = "\n"
 CRLF       = "\r\n"
 TWOCRLF = "\r\n\r\n" // two CRLF
 TWOLF      = "\n"
 )
 
 //Request Class
 type Request struct {
 URL      string
 Method   string
 Protocal string
 Headers
 }
 
 func HandleClientRequest(client net.Conn) {
 if client == nil {
 return
 }
 defer client.Close()
 allBytesNum := 0
 allBytes := []byte{}
 request := Request{}
 request.Headers = make(map[string]string)
 
 
 for {
 buf := make([]byte, BufferSize)
 readBytesNum, err := client.Read(buf)
 if err !  = nil {
 Log.Println ("failed to read byte:"+err.Error ())
 return
 }
 allBytesNum += readBytesNum
 allBytes = append(allBytes, buf[:readBytesNum]...)
 tmpStr := string(allBytes)
 if strings.Contains(TWOCRLF, tmpStr) {
 tmpArr := strings.Split(tmpStr, TWOCRLF)
 break
 } else if strings.Contains(TWOLF, tmpStr) {
 tmpArr := strings.Split(tmpStr, TWOLF)
 break
 }
 }
 //fmt.Println(request)
 }
func (*TCPConn) SetReadBuffer
 func (c *TCPConn) SetReadBuffer(bytes int) error
 SetReadBuffer sets the system receive buffer for this connection
 
 func (*TCPConn) SetWriteBuffer
 func (c *TCPConn) SetWriteBuffer(bytes int) error

Go API
https://studygolang.com/pkgdoc

Same as setReceiveBufferSize in java