被httpclient恶心到了,搞了半天终于解决了

BasicCookieStore cookies = new BasicCookieStore();
cookies.addCookie(new BasicClientCookie("userId", this.userId));
HttpClients.custom()
.setDefaultCookieStore(cookies)//设置Cookie
.setDefaultHeaders(transferMapToHeaderArray(headers))//设置Header
.build();
这样会导致设置的cookie不起作用,原因是
BasicClientCookie有一个domain参数是设置起作用的域名,不设置默认所有域名不起作用
将上面的改成这样就可以了
BasicClientCookie bc1 = new BasicClientCookie("userId", this.userId);
bc1.setDomain("api.io.mi.com");