试图获得与OrientDB错误505的http连接

时间:2016-02-02 02:26:08

标签: android http orientdb

我正在尝试从Android设备到在Linux服务器上运行的OrientDB建立http连接。我收到不支持505 HTTP版本的响应代码。我认为没有版本问题。 Curl命令使用-0选项设置,我试图使用以下作为我的连接http字符串“连接”到数据库:

myUrl是一个String,其值为: http://192.168.1.67:2480/connect/GratefulDeadConcerts

命令:

curl -u root:root http://192.168.1.67:2480/connect/GratefulDeadConcerts

作品。

感谢。

以下是代码:

    String contentAsString = null;
    String userpass = "Basic" + "root" + ":" + "root12";
    String basicAuth = new         String(Base64.encode(userpass.getBytes(), Base64.DEFAULT));

    try {
        URL url = new URL(myUrl);
        HttpURLConnection conn = (HttpURLConnection)        url.openConnection();
        conn.setReadTimeout(10000);
        conn.setConnectTimeout(15000);
        conn.setRequestMethod("GET");
        conn.setDoInput(true);
        conn.setRequestProperty("Accept-Encoding", "gzip,deflate");
        conn.setRequestProperty("Authorization", basicAuth);
        conn.setRequestProperty("Accept", "application/json");
        //conn.setRequestProperty("Content-Length", "1024");

        // Query
        conn.connect();
        int response = conn.getResponseCode();
        Logging.log("Connection", "The respond code is:" + response);
        //is = conn.getInputStream();

        // Convert the InputStream into a Stream

        //contentAsString = readIt(is, len);


    } 

1 个答案:

答案 0 :(得分:1)

我认为问题出在user64的base64转换中。 试试这个:

String userpass = "root" + ":" + "root12";

然后是授权属性:

conn.setRequestProperty("Authorization", "Basic "+ basicAuth);