@@ -790,7 +790,7 @@ public void unicode(String scheme) throws Exception {
790790 @ Test (dataProvider = "schemes" )
791791 public void utf8HeaderValues (String scheme ) throws Exception {
792792
793- String city = "São Paulo" ;
793+ var city = "São Paulo" ;
794794
795795 HTTPHandler handler = (req , res ) -> {
796796 res .setHeader (Headers .ContentType , "text/plain" );
@@ -807,28 +807,31 @@ public void utf8HeaderValues(String scheme) throws Exception {
807807 }
808808 };
809809
810- // Java HTTPClient only supports ASCII header values, so send it directly
811- try (HTTPServer ignore = makeServer (scheme , handler ).start (); Socket sock = new Socket ("127.0.0.1" , 4242 )) {
810+ // Java HttpClient only supports ASCII header values, so send request directly
811+ try (HTTPServer ignore = makeServer (scheme , handler ).start ();
812+ Socket sock = makeClientSocket (scheme )) {
813+
812814 var os = sock .getOutputStream ();
813815 var is = sock .getInputStream ();
814- os .write ("""
815- GET /api/status HTTP/1.1\r
816- Host: localhost:42\r
817- X-Request-Header: São Paulo\r
818- \r
819- """ .getBytes (StandardCharsets .UTF_8 ));
816+ os .write (String .format ("""
817+ GET /api/status HTTP/1.1\r
818+ Host: localhost:42\r
819+ X-Request-Header: %s\r
820+ \r
821+ """ , city )
822+ .getBytes (StandardCharsets .UTF_8 ));
820823 os .flush ();
821824
822825 var resp = new String (is .readAllBytes (), StandardCharsets .UTF_8 );
823826
824- assertEquals (resp , """
827+ assertEquals (resp , String . format ( """
825828 HTTP/1.1 200 \r
826829 content-length: 16\r
827830 content-type: text/plain\r
828831 connection: keep-alive\r
829- x-response-header: São Paulo \r
832+ x-response-header: %s \r
830833 \r
831- {"version":"42"}""" );
834+ {"version":"42"}""" , city ) );
832835 }
833836 }
834837
0 commit comments