if (query_.length() > 0)
url_.append("?");
url_.append(query_);
- System.out.println("Opening: " + url_);
HttpURLConnection connection =
(HttpURLConnection) new URL(new String(url_)).openConnection();
- System.out.println("Request method: " + method_);
connection.setRequestMethod(method_);
if (contentType_ != null) {
- System.out.println("Content-Type: " + contentType_);
connection.setRequestProperty("Content-Type", contentType_);
connection.setDoOutput(true);
- System.out.println("Body size: " + body_.size());
connection.setFixedLengthStreamingMode(body_.size());
- System.out.println("Body:");
- System.out.println(body_.toString());
connection.getOutputStream().write(body_.toByteArray());
- System.out.println("done...");
}
if (connection.getResponseCode() != HttpURLConnection.HTTP_OK)
throw new IOException("HTTP request failed: "
+ connection.getResponseCode() + " " + connection.getResponseMessage());
- System.out.println("response ok");
return new HttpResponse(connection);
}