keep track of total payload size
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
@ -110,6 +110,7 @@ func (p *Payload) sendDataChunked(data []byte, st State) (*Payload, State) {
|
|||||||
remainingData := data[maxChunkSize:]
|
remainingData := data[maxChunkSize:]
|
||||||
// Chunk remaining data into correct chunks and add them to the list
|
// Chunk remaining data into correct chunks and add them to the list
|
||||||
st.RemainingChunks = append(st.RemainingChunks, slices.Collect(slices.Chunk(remainingData, maxChunkSize))...)
|
st.RemainingChunks = append(st.RemainingChunks, slices.Collect(slices.Chunk(remainingData, maxChunkSize))...)
|
||||||
|
st.TotalPayloadSize = len(st.RemainingChunks) * maxChunkSize
|
||||||
} else {
|
} else {
|
||||||
dataToSend = data
|
dataToSend = data
|
||||||
}
|
}
|
||||||
@ -132,7 +133,7 @@ func (p *Payload) sendNextChunk(st State) (*Payload, State) {
|
|||||||
log.WithField("length", st.TotalPayloadSize).Debug("Total payload size")
|
log.WithField("length", st.TotalPayloadSize).Debug("Total payload size")
|
||||||
return &Payload{
|
return &Payload{
|
||||||
Flags: flags,
|
Flags: flags,
|
||||||
Length: uint32((len(st.RemainingChunks) * maxChunkSize) + 5),
|
Length: uint32(st.TotalPayloadSize),
|
||||||
Data: nextChunk,
|
Data: nextChunk,
|
||||||
}, st
|
}, st
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,10 @@ package tls
|
|||||||
import "crypto/tls"
|
import "crypto/tls"
|
||||||
|
|
||||||
type State struct {
|
type State struct {
|
||||||
HasStarted bool
|
HasStarted bool
|
||||||
RemainingChunks [][]byte
|
RemainingChunks [][]byte
|
||||||
TLS *tls.Conn
|
TotalPayloadSize int
|
||||||
|
TLS *tls.Conn
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewState() State {
|
func NewState() State {
|
||||||
|
Reference in New Issue
Block a user