为了账号安全,请及时绑定邮箱和手机立即绑定

Gemfire 的 Http 响应无效?

Gemfire 的 Http 响应无效?

UYOU 2021-10-17 16:00:48
public class GemfireTest extends SecurityManager {            public static void main(String[] args) throws NameResolutionException, TypeMismatchException, QueryInvocationTargetException, FunctionDomainException, IOException {                System.setProperty("gemfire.locators", "localhost[8091]");                Properties properties = new Properties();             ServerLauncher serverLauncher = new ServerLauncher.Builder()                        .setMemberName("server1")                        .setServerPort(40404)                        .set("start-locator", "localhost[8091]")            .build();                serverLauncher.start();                System.out.println(serverLauncher.status());String restapi ="http://localhost:8091/gemfire-api/v1/";             //   URLConnection urlConnection = new URL(restapi).openConnection();                try {                    URL obj = new URL(restapi);                    HttpURLConnection con = (HttpURLConnection) obj.openConnection();                    con.setRequestMethod("GET");                    con.setRequestProperty("accept","application/json");                    int responseCode = con.getResponseCode();                    System.out.println(responseCode);                   // if (responseCode == HttpURLConnection.HTTP_OK) { // success                        BufferedReader in = new BufferedReader(new InputStreamReader(                                con.getInputStream()));                        String inputLine;                        StringBuffer response = new StringBuffer();                        while ((inputLine = in.readLine()) != null) {                            response.append(inputLine);                        }                        in.close();                        // print result                        System.out.println("reason"+response.toString());获取响应代码:-1,无效的 Http 响应。我该如何解决这个问题?
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 159 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信