许多 JSON 请求在同一连接中
Many JSON request in same connection
我需要执行超过 1 个 JSON 请求,但我无法关闭当前连接
示例代码:
private String[] test(URL url, final URL url2) throws IOException {
String[] test = new String[2];
URLConnection openConnection = url.openConnection();
test[0] = this.formatJSON(openConnection.getInputStream());
url = url2;
test[1] = this.formatJSON(openConnection.getInputStream());
return test;
}
或
private String[] test(URL url, final URL url2) throws IOException {
String[] test = new String[2];
URLConnection openConnection = url.openConnection();
test[0] = this.formatJSON(openConnection.getInputStream());
url.setNewURL(url2);
test[1] = this.formatJSON(openConnection.getInputStream());
return test;
}
有什么选择吗?
解决了!
要在同一会话中执行多个 json 请求,我只需要保存第一个 cookie,然后将其与其他请求一起使用。
我需要执行超过 1 个 JSON 请求,但我无法关闭当前连接
示例代码:
private String[] test(URL url, final URL url2) throws IOException {
String[] test = new String[2];
URLConnection openConnection = url.openConnection();
test[0] = this.formatJSON(openConnection.getInputStream());
url = url2;
test[1] = this.formatJSON(openConnection.getInputStream());
return test;
}
或
private String[] test(URL url, final URL url2) throws IOException {
String[] test = new String[2];
URLConnection openConnection = url.openConnection();
test[0] = this.formatJSON(openConnection.getInputStream());
url.setNewURL(url2);
test[1] = this.formatJSON(openConnection.getInputStream());
return test;
}
有什么选择吗?
解决了!
要在同一会话中执行多个 json 请求,我只需要保存第一个 cookie,然后将其与其他请求一起使用。