java
Java
code posted
created at 23 Aug 17:41
Edit
|
Back
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
HttpGet get = new HttpGet(path); String date = DateUtils.formatDate(new Date()); // create signature: method + content md5 + content-type + date + uri StringBuilder signature = new StringBuilder(); signature.append(get.getMethod()).append("\n") .append("\n") .append("\n") .append(date).append("\n") .append(get.getURI().getPath()); get.addHeader("Date", date); get.addHeader("Authorization", username + ":" + calculateHMAC(password, signature.toString())); // send request HttpClient client = new DefaultHttpClient(); HttpResponse response = client.execute(get); System.out.println(response.getStatusLine().getStatusCode()); |
672 Bytes in 2 ms with coderay