MCPcopy Index your code
hub / github.com/coder/coder / buildMultipartResponse

Function buildMultipartResponse

coderd/x/chatd/recording_internal_test.go:50–64  ·  view source on GitHub ↗

buildMultipartResponse constructs a StopDesktopRecordingResponse with the given content type/data pairs encoded as multipart/mixed.

(parts ...partSpec)

Source from the content-addressed store, hash-verified

48// buildMultipartResponse constructs a StopDesktopRecordingResponse
49// with the given content type/data pairs encoded as multipart/mixed.
50func buildMultipartResponse(parts ...partSpec) workspacesdk.StopDesktopRecordingResponse {
51 var buf bytes.Buffer
52 mw := multipart.NewWriter(&buf)
53 for _, p := range parts {
54 partWriter, _ := mw.CreatePart(textproto.MIMEHeader{
55 "Content-Type": {p.contentType},
56 })
57 _, _ = partWriter.Write(p.data)
58 }
59 _ = mw.Close()
60 return workspacesdk.StopDesktopRecordingResponse{
61 Body: io.NopCloser(bytes.NewReader(buf.Bytes())),
62 ContentType: "multipart/mixed; boundary=" + mw.Boundary(),
63 }
64}
65
66func validRecordingMP4(extra int, fill byte) []byte {
67 data := []byte{0x00, 0x00, 0x00, 0x18, 'f', 't', 'y', 'p', 'm', 'p', '4', '2', 0x00, 0x00, 0x00, 0x00, 'm', 'p', '4', '1', 'i', 's', 'o', 'm'}

Calls 3

WriteMethod · 0.65
CloseMethod · 0.65
BytesMethod · 0.45

Tested by

no test coverage detected