MCPcopy
hub / github.com/valyala/fasthttp / TestRequestMultipartFormPipeEmptyFormField

Function TestRequestMultipartFormPipeEmptyFormField

http_test.go:3612–3656  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3610}
3611
3612func TestRequestMultipartFormPipeEmptyFormField(t *testing.T) {
3613 t.Parallel()
3614
3615 pr, pw := io.Pipe()
3616 mw := multipart.NewWriter(pw)
3617
3618 errs := make(chan error, 1)
3619
3620 go func() {
3621 defer func() {
3622 err := mw.Close()
3623 if err != nil {
3624 errs <- err
3625 }
3626 err = pw.Close()
3627 if err != nil {
3628 errs <- err
3629 }
3630 close(errs)
3631 }()
3632
3633 if err := mw.WriteField("emptyField", ""); err != nil {
3634 errs <- err
3635 }
3636 }()
3637
3638 var b bytes.Buffer
3639 bw := bufio.NewWriter(&b)
3640 err := writeBodyChunked(bw, pr)
3641 if err != nil {
3642 t.Fatalf("unexpected error: %v", err)
3643 }
3644 if _, err = bw.Write(strCRLF); err != nil {
3645 t.Fatalf("unexpected error: %v", err)
3646 }
3647 if err = bw.Flush(); err != nil {
3648 t.Fatalf("unexpected error: %v", err)
3649 }
3650
3651 for e := range errs {
3652 t.Fatalf("unexpected error in goroutine multiwriter: %v", e)
3653 }
3654
3655 testRequestMultipartFormPipeEmptyFormField(t, mw.Boundary(), b.Bytes(), 1)
3656}
3657
3658func testRequestMultipartFormPipeEmptyFormField(t *testing.T, boundary string, formData []byte, partsCount int) []byte {
3659 s := fmt.Sprintf("POST / HTTP/1.1\r\nHost: aaa\r\nContent-Type: multipart/form-data; boundary=%s\r\nTransfer-Encoding: chunked\r\n\r\n%s",

Callers

nothing calls this directly

Calls 6

CloseMethod · 0.95
WriteMethod · 0.95
FlushMethod · 0.95
writeBodyChunkedFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…