Search in sources :

Example 6 with AsyncHttpPost

use of com.koushikdutta.async.http.AsyncHttpPost in project AndroidAsync by koush.

the class HttpServerTests method testJSONObject.

public void testJSONObject() throws Exception {
    JSONObject json = new JSONObject();
    json.put("foo", "bar");
    JSONObjectBody body = new JSONObjectBody(json);
    AsyncHttpPost post = new AsyncHttpPost("http://localhost:5000/echo");
    post.setBody(body);
    json = AsyncHttpClient.getDefaultInstance().executeJSONObject(post, null).get();
    assertEquals(json.getString("foo"), "bar");
}
Also used : JSONObjectBody(com.koushikdutta.async.http.body.JSONObjectBody) JSONObject(org.json.JSONObject) AsyncHttpPost(com.koushikdutta.async.http.AsyncHttpPost)

Example 7 with AsyncHttpPost

use of com.koushikdutta.async.http.AsyncHttpPost in project AndroidAsync by koush.

the class XHRPollingTransport method postMessage.

private void postMessage(String message) {
    if (!message.startsWith("5"))
        return;
    AsyncHttpRequest request = new AsyncHttpPost(computedRequestUrl());
    request.setBody(new StringBody(message));
    client.executeString(request, null);
}
Also used : StringBody(com.koushikdutta.async.http.body.StringBody) AsyncHttpPost(com.koushikdutta.async.http.AsyncHttpPost) AsyncHttpRequest(com.koushikdutta.async.http.AsyncHttpRequest)

Example 8 with AsyncHttpPost

use of com.koushikdutta.async.http.AsyncHttpPost in project simperium-android by Simperium.

the class AsyncAuthClient method buildRequest.

public AsyncHttpPost buildRequest(String path, JSONObject body) {
    Uri uri = buildUri(path);
    AsyncHttpPost request = new AsyncHttpPost(uri);
    request.setBody(new JSONObjectBody(body));
    request.setHeader(API_KEY_HEADER_NAME, mSecret);
    return request;
}
Also used : JSONObjectBody(com.koushikdutta.async.http.body.JSONObjectBody) Uri(android.net.Uri) AsyncHttpPost(com.koushikdutta.async.http.AsyncHttpPost)

Aggregations

AsyncHttpPost (com.koushikdutta.async.http.AsyncHttpPost)8 AsyncHttpResponse (com.koushikdutta.async.http.AsyncHttpResponse)3 JSONObjectBody (com.koushikdutta.async.http.body.JSONObjectBody)3 StringBody (com.koushikdutta.async.http.body.StringBody)3 JSONObject (org.json.JSONObject)3 AsyncHttpClient (com.koushikdutta.async.http.AsyncHttpClient)2 AsyncHttpRequest (com.koushikdutta.async.http.AsyncHttpRequest)2 File (java.io.File)2 Bitmap (android.graphics.Bitmap)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 Uri (android.net.Uri)1 ImageView (android.widget.ImageView)1 StringCallback (com.koushikdutta.async.http.AsyncHttpClient.StringCallback)1 BasicNameValuePair (com.koushikdutta.async.http.BasicNameValuePair)1 NameValuePair (com.koushikdutta.async.http.NameValuePair)1 MultipartFormDataBody (com.koushikdutta.async.http.body.MultipartFormDataBody)1 UrlEncodedFormBody (com.koushikdutta.async.http.body.UrlEncodedFormBody)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1