@@ -729,11 +729,13 @@ public void handle(Request request, HttpServletResponse response) {
729
729
@ Test
730
730
public void postForm () throws Exception {
731
731
final AtomicReference <String > body = new AtomicReference <String >();
732
+ final AtomicReference <String > contentType = new AtomicReference <String >();
732
733
handler = new RequestHandler () {
733
734
734
735
@ Override
735
736
public void handle (Request request , HttpServletResponse response ) {
736
737
body .set (new String (read ()));
738
+ contentType .set (request .getContentType ());
737
739
response .setStatus (HTTP_OK );
738
740
}
739
741
};
@@ -743,6 +745,35 @@ public void handle(Request request, HttpServletResponse response) {
743
745
int code = post (url ).form (data ).form ("zip" , "12345" ).code ();
744
746
assertEquals (HTTP_OK , code );
745
747
assertEquals ("name=user&number=100&zip=12345" , body .get ());
748
+ assertEquals ("application/x-www-form-urlencoded; charset=UTF-8" ,
749
+ contentType .get ());
750
+ }
751
+
752
+ /**
753
+ * Make a post of form data
754
+ *
755
+ * @throws Exception
756
+ */
757
+ @ Test
758
+ public void postFormWithNoCharset () throws Exception {
759
+ final AtomicReference <String > body = new AtomicReference <String >();
760
+ final AtomicReference <String > contentType = new AtomicReference <String >();
761
+ handler = new RequestHandler () {
762
+
763
+ @ Override
764
+ public void handle (Request request , HttpServletResponse response ) {
765
+ body .set (new String (read ()));
766
+ contentType .set (request .getContentType ());
767
+ response .setStatus (HTTP_OK );
768
+ }
769
+ };
770
+ Map <String , String > data = new LinkedHashMap <String , String >();
771
+ data .put ("name" , "user" );
772
+ data .put ("number" , "100" );
773
+ int code = post (url ).form (data , null ).form ("zip" , "12345" ).code ();
774
+ assertEquals (HTTP_OK , code );
775
+ assertEquals ("name=user&number=100&zip=12345" , body .get ());
776
+ assertEquals ("application/x-www-form-urlencoded" , contentType .get ());
746
777
}
747
778
748
779
/**
0 commit comments