@@ -790,7 +790,7 @@ public void unicode(String scheme) throws Exception {
790
790
@ Test (dataProvider = "schemes" )
791
791
public void utf8HeaderValues (String scheme ) throws Exception {
792
792
793
- String city = "São Paulo" ;
793
+ var city = "São Paulo" ;
794
794
795
795
HTTPHandler handler = (req , res ) -> {
796
796
res .setHeader (Headers .ContentType , "text/plain" );
@@ -807,28 +807,31 @@ public void utf8HeaderValues(String scheme) throws Exception {
807
807
}
808
808
};
809
809
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
+
812
814
var os = sock .getOutputStream ();
813
815
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 ));
820
823
os .flush ();
821
824
822
825
var resp = new String (is .readAllBytes (), StandardCharsets .UTF_8 );
823
826
824
- assertEquals (resp , """
827
+ assertEquals (resp , String . format ( """
825
828
HTTP/1.1 200 \r
826
829
content-length: 16\r
827
830
content-type: text/plain\r
828
831
connection: keep-alive\r
829
- x-response-header: São Paulo \r
832
+ x-response-header: %s \r
830
833
\r
831
- {"version":"42"}""" );
834
+ {"version":"42"}""" , city ) );
832
835
}
833
836
}
834
837
0 commit comments