@@ -34,7 +34,7 @@ public HttpApiClient(String name, Map<String, String> defaultHeaders, Map<String
3434 this .cookieManager .setCookiePolicy (CookiePolicy .ACCEPT_ALL );
3535 this .client = HttpClient .newBuilder ().cookieHandler (this .cookieManager ).build ();
3636 this .defaultHeaders = defaultHeaders ;
37- this .cookieFile . read ( this . cookieManager );
37+ this .readCookie ( );
3838 initCookies .forEach ((url , list ) -> {
3939 try {
4040 this .cookieManager .put (new URI (url ), Map .of ("Set-Cookie" , list ));
@@ -67,10 +67,14 @@ public String getName() {
6767 return this .name ;
6868 }
6969
70- public void updateCookie () {
70+ public void writeCookie () {
7171 this .cookieFile .write (this .cookieManager );
7272 }
7373
74+ public void readCookie () {
75+ this .cookieFile .read (this .cookieManager );
76+ }
77+
7478 public void clearCookie () {
7579 this .cookieManager = new CookieManager ();
7680 this .cookieManager .setCookiePolicy (CookiePolicy .ACCEPT_ALL );
@@ -91,11 +95,11 @@ public String getCookie(String url, String key) throws IOException, URISyntaxExc
9195
9296 public void setCookie (String url , String key , String value ) throws IOException , URISyntaxException {
9397 this .cookieManager .put (new URI (url ), Map .of ("Set-Cookie" , List .of (key + "=" + value )));
94- this .updateCookie ();
98+ this .writeCookie ();
9599 }
96100
97101 public static Map <Character , Character > ESCAPE_MAP = Map .of (
98- '\u00a0' , ' ' , '\r' , '\n'
102+ '\u00a0' , ' ' , '\ufeff' , ' ' , '\ r' , '\n'
99103 ); // escape illegal spaces
100104
101105 public static String escapeChars (String string ) {
0 commit comments