Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 73: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 74: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 75: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 76: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 77: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 78: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
import java.io.ByteArrayInputStream; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; import org.apache.http.util.ByteArrayBuffer; import android.content.Context; import android.net.http.EventHandler; import android.net.http.Headers; import android.net.http.RequestQueue; import android.net.http.SslCertificate; import android.util.Log; /*** * Perform GET or POST requests easily and handle responses, status checks, and errors. * Encapsulated in a class by Nanodeath * @author plusminus * @author nanodeath * */ public class HTTP_Request { // Fields private Context context; private String url; private Method method; /*** * Possible modes to make requests */ public enum Method { POST, GET } // Constructors public HTTP_Request(Context c, String url, Method method) { this.context = c; this.url = url; this.method = method; } private ResponseHandler handler; /*** * Optionally, you can process any output the url generates when accessed. You can do so here. * @param h The response handler you want this object to use */ public void setHandler(ResponseHandler h){ handler = h; } /*** * Initiates the defined HTTP_Request without any variables */ public void go(){ go(null); } /*** * Initiates the defined HTTP_Request with the given variables as arguments * @param variables Key,value pairs to be sent to the webservice */ public void go(Map variables){ if(handler == null){ handler = new ResponseHandler(); } /* Create a new EventHandler defined above, to handle what gets returned. */ MyEventHandler myEvH = new MyEventHandler(handler); /* Create a new HTTP-RequestQueue. */ android.net.http.RequestQueue rQueue = new RequestQueue(context); /* Create a header-hashmap */ Map headers = new HashMap(); /* and put the Default-Encoding for html-forms to it. */ headers.put("Content-Type", "application/x-www-form-urlencoded"); /* Prepare the variables we are going to send. */ String variablesURL; if(variables != null && variables.size() > 0){ try { StringBuilder b = new StringBuilder(); Set keys = variables.keySet(); // Iterate over each variable you want and append it to our variablesURL variable for(Iterator i = keys.iterator();;){ String key = i.next(); b.append(key); b.append("="); b.append(URLEncoder.encode(variables.get(key), "UTF-8")); // Minor speed optimization so that i.hasNext() is only called once (instead of in the for loop). if(i.hasNext()){ b.append("&"); } else { break; } } variablesURL = b.toString(); } catch (UnsupportedEncodingException e) { Log.e("HTTP_Request", "Unsupported Encoding Exception"); return; } } else { variablesURL = ""; } if(method == Method.GET){ // Perform the request with GET if(!variablesURL.equals("")){ url = url + "?" + variablesURL; } rQueue.queueRequest(url, "GET", headers, myEvH, null, 0, false); } else if(method == Method.POST){ /* And put the encoded bytes into an BAIS, * where a function later can read bytes from. */ byte[] POSTbytes = variablesURL.getBytes(); ByteArrayInputStream baos = new ByteArrayInputStream(POSTbytes); rQueue.queueRequest(url, "POST", headers, myEvH, baos, POSTbytes.length, false); } else { // Hopefully this could never actually occur return; } /* Wait until the request is complete.*/ rQueue.waitUntilComplete(); } // =========================================================== // Worker Class // =========================================================== private class MyEventHandler implements EventHandler { private ResponseHandler handler; /** Will hold the data returned by the URLCall. */ ByteArrayBuffer baf = new ByteArrayBuffer(20); MyEventHandler(ResponseHandler callback) { this.handler = callback; } public void data(byte[] bytes, int len) { baf.append(bytes, 0, len); } public void endData() { handler.run(new String(baf.toByteArray())); } public void status(int arg0, int arg1, int HTTPstatusCode, String status) { // HTTPstatusCode can be 200 for OK, 404 for Not Found, etc. // Status can be OK, Not Found, others... handler.status(status); } public void error(int i, String s) { handler.error(s); } public void handleSslErrorRequest(int arg0, String arg1, SslCertificate arg2) { } public void headers(Iterator arg0) { } public void headers(Headers arg0) { } } public static class ResponseHandler { public void run(String response){} public void status(String status) {} public void error(String error) {} } }