List of usage examples for org.apache.http.client.methods HttpReport HttpReport
public HttpReport()
From source file:de.azapps.mirakel.sync.Network.java
private String downloadUrl(String myurl) throws IOException, URISyntaxException { if (token != null) { myurl += "?authentication_key=" + token; }/*from w w w .ja va 2s . c o m*/ if (myurl.indexOf("https") == -1) { Integer[] t = { NoHTTPS }; publishProgress(t); } /* * String authorizationString = null; * if (syncTyp == ACCOUNT_TYPES.CALDAV) { * authorizationString = "Basic " * + Base64.encodeToString( * (username + ":" + password).getBytes(), * Base64.NO_WRAP); * } */ CredentialsProvider credentials = new BasicCredentialsProvider(); credentials.setCredentials(new AuthScope(new URI(myurl).getHost(), -1), new UsernamePasswordCredentials(username, password)); HttpParams params = new BasicHttpParams(); params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); HttpConnectionParams.setTcpNoDelay(params, true); HttpClient httpClient; /* * if(syncTyp == ACCOUNT_TYPES.MIRAKEL) * httpClient = sslClient(client); * else { */ DefaultHttpClient tmpHttpClient = new DefaultHttpClient(params); tmpHttpClient.setCredentialsProvider(credentials); httpClient = tmpHttpClient; // } httpClient.getParams().setParameter("http.protocol.content-charset", HTTP.UTF_8); HttpResponse response; try { switch (mode) { case GET: Log.v(TAG, "GET " + myurl); HttpGet get = new HttpGet(); get.setURI(new URI(myurl)); response = httpClient.execute(get); break; case PUT: Log.v(TAG, "PUT " + myurl); HttpPut put = new HttpPut(); if (syncTyp == ACCOUNT_TYPES.CALDAV) { put.addHeader(HTTP.CONTENT_TYPE, "text/calendar; charset=utf-8"); } put.setURI(new URI(myurl)); put.setEntity(new StringEntity(content, HTTP.UTF_8)); Log.v(TAG, content); response = httpClient.execute(put); break; case POST: Log.v(TAG, "POST " + myurl); HttpPost post = new HttpPost(); post.setURI(new URI(myurl)); post.setEntity(new UrlEncodedFormEntity(headerData, HTTP.UTF_8)); response = httpClient.execute(post); break; case DELETE: Log.v(TAG, "DELETE " + myurl); HttpDelete delete = new HttpDelete(); delete.setURI(new URI(myurl)); response = httpClient.execute(delete); break; case REPORT: Log.v(TAG, "REPORT " + myurl); HttpReport report = new HttpReport(); report.setURI(new URI(myurl)); Log.d(TAG, content); report.setEntity(new StringEntity(content, HTTP.UTF_8)); response = httpClient.execute(report); break; default: Log.wtf("HTTP-MODE", "Unknown Http-Mode"); return null; } } catch (Exception e) { Log.e(TAG, "No Networkconnection available"); Log.w(TAG, Log.getStackTraceString(e)); return ""; } Log.v(TAG, "Http-Status: " + response.getStatusLine().getStatusCode()); if (response.getEntity() == null) return ""; String r = EntityUtils.toString(response.getEntity(), HTTP.UTF_8); Log.d(TAG, r); return r; }