(t *testing.T)
| 1442 | } |
| 1443 | |
| 1444 | func TestServerMultipartFormDataRequest(t *testing.T) { |
| 1445 | t.Parallel() |
| 1446 | |
| 1447 | for _, test := range []struct { |
| 1448 | StreamRequestBody bool |
| 1449 | DisablePreParseMultipartForm bool |
| 1450 | }{ |
| 1451 | {StreamRequestBody: false, DisablePreParseMultipartForm: false}, |
| 1452 | {StreamRequestBody: false, DisablePreParseMultipartForm: true}, |
| 1453 | {StreamRequestBody: true, DisablePreParseMultipartForm: false}, |
| 1454 | {StreamRequestBody: true, DisablePreParseMultipartForm: true}, |
| 1455 | } { |
| 1456 | b := strings.ReplaceAll(`------WebKitFormBoundaryJwfATyF8tmxSJnLg |
| 1457 | Content-Disposition: form-data; name="f1" |
| 1458 | |
| 1459 | value1 |
| 1460 | ------WebKitFormBoundaryJwfATyF8tmxSJnLg |
| 1461 | Content-Disposition: form-data; name="fileaaa"; filename="TODO" |
| 1462 | Content-Type: application/octet-stream |
| 1463 | |
| 1464 | - SessionClient with referer and cookies support. |
| 1465 | - Client with requests' pipelining support. |
| 1466 | - ProxyHandler similar to FSHandler. |
| 1467 | - WebSockets. See https://tools.ietf.org/html/rfc6455 . |
| 1468 | - HTTP/2.0. See https://tools.ietf.org/html/rfc7540 . |
| 1469 | |
| 1470 | ------WebKitFormBoundaryJwfATyF8tmxSJnLg-- |
| 1471 | `, "\n", "\r\n") |
| 1472 | |
| 1473 | reqS := fmt.Sprintf(strings.ReplaceAll(`POST /upload HTTP/1.1 |
| 1474 | Host: qwerty.com |
| 1475 | Content-Length: %d |
| 1476 | Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryJwfATyF8tmxSJnLg |
| 1477 | |
| 1478 | %s |
| 1479 | |
| 1480 | GET / HTTP/1.1 |
| 1481 | Host: asbd |
| 1482 | Connection: close |
| 1483 | |
| 1484 | `, "\n", "\r\n"), len(b), b) |
| 1485 | |
| 1486 | ln := fasthttputil.NewInmemoryListener() |
| 1487 | |
| 1488 | s := &Server{ |
| 1489 | StreamRequestBody: test.StreamRequestBody, |
| 1490 | DisablePreParseMultipartForm: test.DisablePreParseMultipartForm, |
| 1491 | Handler: func(ctx *RequestCtx) { |
| 1492 | switch string(ctx.Path()) { |
| 1493 | case "/upload": |
| 1494 | f, err := ctx.MultipartForm() |
| 1495 | if err != nil { |
| 1496 | t.Errorf("unexpected error: %v", err) |
| 1497 | } |
| 1498 | if len(f.Value) != 1 { |
| 1499 | t.Errorf("unexpected values %d. Expecting %d", len(f.Value), 1) |
| 1500 | } |
| 1501 | if len(f.File) != 1 { |
nothing calls this directly
no test coverage detected
searching dependent graphs…