Database Reference
In-Depth Information
"User-Agent",
CommandRunner.class.getCanonicalName());
conn.setDoInput(true);
conn.setDoOutput(true);
return conn;
} catch (IOException ex) {
throw new ErrorResult(ex);
}
}
// Opens the connection and performs the HTTP POST
operation.
private int sendRequest(HttpURLConnection conn,
byte[] body)
throws ErrorResult {
conn.setRequestProperty("Content-Type",
"application/json");
conn.setFixedLengthStreamingMode(body.length);
try {
conn.setRequestMethod("POST");
conn.connect();
OutputStream os = conn.getOutputStream();
try {
os.write(body);
} finally {
os.close();
}
return conn.getResponseCode();
} catch (IOException ex) {
throw new ErrorResult(ex);
}
}
// Reads the response body from the HTTP connection.
private String readResponse(HttpURLConnection conn)
throws ErrorResult {
int contentLength = conn.getContentLength();
try {
Search WWH ::




Custom Search