@@ -510,6 +510,58 @@ func TestHandler_FormData_POST(t *testing.T) {
510
510
assert .Equal (t , `{"arr":{"c":{"p":"l","z":""},"x":{"y":{"e":"f","z":"y"}}},"key":"value","name":["name1","name2","name3"]}` , string (b ))
511
511
}
512
512
513
+ func TestHandler_FormData_POST_Overwrite (t * testing.T ) {
514
+ h := & Handler {
515
+ cfg : & Config {
516
+ MaxRequest : 1024 ,
517
+ Uploads : & UploadsConfig {
518
+ Dir : os .TempDir (),
519
+ Forbid : []string {},
520
+ },
521
+ },
522
+ rr : roadrunner .NewServer (& roadrunner.ServerConfig {
523
+ Command : "php ../../tests/http/client.php data pipes" ,
524
+ Relay : "pipes" ,
525
+ Pool : & roadrunner.Config {
526
+ NumWorkers : 1 ,
527
+ AllocateTimeout : 10000000 ,
528
+ DestroyTimeout : 10000000 ,
529
+ },
530
+ }),
531
+ }
532
+
533
+ assert .NoError (t , h .rr .Start ())
534
+ defer h .rr .Stop ()
535
+
536
+ hs := & http.Server {Addr : ":8083" , Handler : h }
537
+ defer hs .Shutdown (context .Background ())
538
+
539
+ go func () { hs .ListenAndServe () }()
540
+ time .Sleep (time .Millisecond * 10 )
541
+
542
+ form := url.Values {}
543
+
544
+ form .Add ("key" , "value1" )
545
+ form .Add ("key" , "value2" )
546
+
547
+ req , err := http .NewRequest ("POST" , "http://localhost" + hs .Addr , strings .NewReader (form .Encode ()))
548
+ assert .NoError (t , err )
549
+
550
+ req .Header .Add ("Content-Type" , "application/x-www-form-urlencoded" )
551
+
552
+ r , err := http .DefaultClient .Do (req )
553
+ assert .NoError (t , err )
554
+ defer r .Body .Close ()
555
+
556
+ b , err := ioutil .ReadAll (r .Body )
557
+ assert .NoError (t , err )
558
+
559
+ assert .NoError (t , err )
560
+ assert .Equal (t , 200 , r .StatusCode )
561
+
562
+ assert .Equal (t , `{"key":"value2","arr":{"x":{"y":null}}}` , string (b ))
563
+ }
564
+
513
565
func TestHandler_FormData_POST_Form_UrlEncoded_Charset (t * testing.T ) {
514
566
h := & Handler {
515
567
cfg : & Config {
0 commit comments