MCPcopy
hub / github.com/keploy/keploy / parseMultipartQueue

Function parseMultipartQueue

pkg/util.go:1754–1779  ·  view source on GitHub ↗
(reader io.Reader, boundary string)

Source from the content-addressed store, hash-verified

1752}
1753
1754func parseMultipartQueue(reader io.Reader, boundary string) ([]multipartPartPayload, error) {
1755 if strings.TrimSpace(boundary) == "" {
1756 return nil, fmt.Errorf("multipart boundary is empty")
1757 }
1758
1759 data, err := io.ReadAll(reader)
1760 if err != nil {
1761 return nil, err
1762 }
1763
1764 queue, parseErr := parseMultipartQueueBytes(data, boundary)
1765 if parseErr == nil {
1766 return queue, nil
1767 }
1768
1769 closingBoundary := []byte("--" + boundary + "--")
1770 if !bytes.Contains(data, closingBoundary) {
1771 patchedData := append([]byte{}, data...)
1772 patchedData = append(patchedData, []byte("\r\n--"+boundary+"--\r\n")...)
1773 if patchedQueue, patchedErr := parseMultipartQueueBytes(patchedData, boundary); patchedErr == nil {
1774 return patchedQueue, nil
1775 }
1776 }
1777
1778 return nil, parseErr
1779}
1780
1781func parseMultipartQueueBytes(data []byte, boundary string) ([]multipartPartPayload, error) {
1782 mr := multipart.NewReader(bytes.NewReader(data), boundary)

Callers 1

compareMultipartStreamFunction · 0.85

Calls 1

parseMultipartQueueBytesFunction · 0.85

Tested by

no test coverage detected