/** * * Display an HTTP response header information. * * @param response The response whose information must be displayed. */ public static void displayResponseHeaders(HttpResponse response) { HttpHeaders headers = response.getHeaders(); // Get the file list iterator. Iterator<Entry<String, Object>> iterator = headers.entrySet().iterator(); System.out.println( String.format("%n================== " + "Response Headers" + " ================== %n")); while (iterator.hasNext()) { Entry<String, Object> entry = iterator.next(); String key = entry.getKey(); String value = entry.getValue().toString(); System.out.println(String.format("Key: %s Value: %s", key, value)); } }
private String initUpload( HttpRequestFactory requestFactory, DocsUrl url, long size, String fileType, AtomContent fileContent) throws IOException { HttpRequest request = requestFactory.buildPostRequest(url, fileContent); request.getHeaders().set("X-Upload-Content-Type", fileType); request.getHeaders().set("X-Upload-Content-Length", size); HttpResponse response = requestExecutor.executeNonSensitive(request); if (!response.isSuccessStatusCode()) { throw new CoreException( "unable to initiate upload, " + response.getStatusCode() + ": " + response.getStatusMessage()); } response.ignore(); return response.getHeaders().getLocation(); }