MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / mergeFileBodySource

Function mergeFileBodySource

internal/api/middleware/response_writer.go:635–655  ·  view source on GitHub ↗
(payload []byte, source *logging.FileBodySource)

Source from the content-addressed store, hash-verified

633}
634
635func mergeFileBodySource(payload []byte, source *logging.FileBodySource) ([]byte, error) {
636 if source == nil {
637 return payload, nil
638 }
639 defer cleanupFileBodySources(source)
640 if !source.HasPayload() {
641 return payload, nil
642 }
643 var buf bytes.Buffer
644 if len(payload) > 0 {
645 buf.Write(payload)
646 if !bytes.HasSuffix(payload, []byte("\n")) {
647 buf.WriteByte('\n')
648 }
649 buf.WriteByte('\n')
650 }
651 if errWrite := source.WriteTo(&buf); errWrite != nil {
652 return nil, errWrite
653 }
654 return buf.Bytes(), nil
655}
656
657func cleanupFileBodySources(sources ...*logging.FileBodySource) {
658 for _, source := range sources {

Callers 2

FinalizeMethod · 0.85
logRequestMethod · 0.85

Calls 5

HasPayloadMethod · 0.80
WriteToMethod · 0.80
BytesMethod · 0.80
cleanupFileBodySourcesFunction · 0.70
WriteMethod · 0.45

Tested by

no test coverage detected