Reputation: 125
I am trying to make a http connection from an android device to OrientDB running on a Linux server. I receive a response code of 505 HTTP version not supported. I don't think there is a version problem. The Curl command work with the -0 option set, I am trying to "connect" to the database using the following as my connect http string:
myUrl is a String its value is : http://192.168.1.67:2480/connect/GratefulDeadConcerts
The command:
curl -u root:root http://192.168.1.67:2480/connect/GratefulDeadConcerts
Works.
Thanks.
Here is the code:
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);
}
Upvotes: 0
Views: 155
Reputation: 1982
I think the problem is in the base64 conversion of userpass. Try this:
String userpass = "root" + ":" + "root12";
and then the authorization property:
conn.setRequestProperty("Authorization", "Basic "+ basicAuth);
Upvotes: 1