Remove not needed chunking code
This commit is contained in:
parent
192eccc6cc
commit
b5e2871aa0
@ -97,6 +97,7 @@ func (self *wrapped_serializer) next(io_data *rc_io_data) ([]byte, error) {
|
|||||||
} else {
|
} else {
|
||||||
self.all_payloads_done = true
|
self.all_payloads_done = true
|
||||||
}
|
}
|
||||||
|
self.state++
|
||||||
return self.serializer(io_data.rc)
|
return self.serializer(io_data.rc)
|
||||||
case 2:
|
case 2:
|
||||||
if self.all_payloads_done {
|
if self.all_payloads_done {
|
||||||
@ -168,33 +169,15 @@ type rc_io_data struct {
|
|||||||
string_response_is_err bool
|
string_response_is_err bool
|
||||||
timeout time.Duration
|
timeout time.Duration
|
||||||
multiple_payload_generator func(io_data *rc_io_data) (bool, error)
|
multiple_payload_generator func(io_data *rc_io_data) (bool, error)
|
||||||
|
|
||||||
pending_chunks [][]byte
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *rc_io_data) next_chunk(limit_size bool) (chunk []byte, err error) {
|
func (self *rc_io_data) next_chunk() (chunk []byte, err error) {
|
||||||
if len(self.pending_chunks) > 0 {
|
|
||||||
chunk = self.pending_chunks[0]
|
|
||||||
copy(self.pending_chunks, self.pending_chunks[1:])
|
|
||||||
self.pending_chunks = self.pending_chunks[:len(self.pending_chunks)-1]
|
|
||||||
return
|
|
||||||
}
|
|
||||||
block, err := self.serializer.next(self)
|
block, err := self.serializer.next(self)
|
||||||
if err != nil && !errors.Is(err, io.EOF) {
|
if err != nil && !errors.Is(err, io.EOF) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = nil
|
err = nil
|
||||||
const limit = 2048
|
chunk = block
|
||||||
if !limit_size || len(block) < limit {
|
|
||||||
chunk = block
|
|
||||||
return
|
|
||||||
}
|
|
||||||
chunk = block[:limit]
|
|
||||||
block = block[limit:]
|
|
||||||
for len(block) > 0 {
|
|
||||||
self.pending_chunks = append(self.pending_chunks, block[:limit])
|
|
||||||
block = block[limit:]
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -54,7 +54,7 @@ func read_response_from_conn(conn *net.Conn, timeout time.Duration) (serialized_
|
|||||||
func simple_socket_io(conn *net.Conn, io_data *rc_io_data) (serialized_response []byte, err error) {
|
func simple_socket_io(conn *net.Conn, io_data *rc_io_data) (serialized_response []byte, err error) {
|
||||||
for {
|
for {
|
||||||
var chunk []byte
|
var chunk []byte
|
||||||
chunk, err = io_data.next_chunk(false)
|
chunk, err = io_data.next_chunk()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,7 +44,7 @@ func do_chunked_io(io_data *rc_io_data) (serialized_response []byte, err error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
lp.OnInitialize = func() (string, error) {
|
lp.OnInitialize = func() (string, error) {
|
||||||
chunk, err := io_data.next_chunk(false)
|
chunk, err := io_data.next_chunk()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ func do_chunked_io(io_data *rc_io_data) (serialized_response []byte, err error)
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
chunk, err := io_data.next_chunk(false)
|
chunk, err := io_data.next_chunk()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user