@@ -515,7 +515,24 @@ def _test_post__no_data(http)
515515 end
516516 end
517517
518- def test_s_post
518+ def test_s_post_with_uri_string
519+ url = "http://#{ config ( 'host' ) } :#{ config ( 'port' ) } /?q=a"
520+ res = Net ::HTTP . post (
521+ url ,
522+ "a=x" )
523+ assert_equal "application/octet-stream" , res [ "Content-Type" ]
524+ assert_equal "a=x" , res . body
525+ assert_equal url , res [ "X-request-uri" ]
526+
527+ res = Net ::HTTP . post (
528+ url ,
529+ "hello world" ,
530+ "Content-Type" => "text/plain; charset=US-ASCII" )
531+ assert_equal "text/plain; charset=US-ASCII" , res [ "Content-Type" ]
532+ assert_equal "hello world" , res . body
533+ end
534+
535+ def test_s_post_with_uri
519536 url = "http://#{ config ( 'host' ) } :#{ config ( 'port' ) } /?q=a"
520537 res = Net ::HTTP . post (
521538 URI . parse ( url ) ,
@@ -532,7 +549,34 @@ def test_s_post
532549 assert_equal "hello world" , res . body
533550 end
534551
535- def test_s_post_form
552+ def test_s_post_form_with_uri_string
553+ url = "http://#{ config ( 'host' ) } :#{ config ( 'port' ) } /"
554+ res = Net ::HTTP . post_form (
555+ url ,
556+ "a" => "x" )
557+ assert_equal [ "a=x" ] , res . body . split ( /[;&]/ ) . sort
558+
559+ res = Net ::HTTP . post_form (
560+ url ,
561+ "a" => "x" ,
562+ "b" => "y" )
563+ assert_equal [ "a=x" , "b=y" ] , res . body . split ( /[;&]/ ) . sort
564+
565+ res = Net ::HTTP . post_form (
566+ url ,
567+ "a" => [ "x1" , "x2" ] ,
568+ "b" => "y" )
569+ assert_equal url , res [ 'X-request-uri' ]
570+ assert_equal [ "a=x1" , "a=x2" , "b=y" ] , res . body . split ( /[;&]/ ) . sort
571+
572+ res = Net ::HTTP . post_form (
573+ url + '?a=x' ,
574+ "b" => "y" )
575+ assert_equal url + '?a=x' , res [ 'X-request-uri' ]
576+ assert_equal [ "b=y" ] , res . body . split ( /[;&]/ ) . sort
577+ end
578+
579+ def test_s_post_form_with_uri
536580 url = "http://#{ config ( 'host' ) } :#{ config ( 'port' ) } /"
537581 res = Net ::HTTP . post_form (
538582 URI . parse ( url ) ,
0 commit comments