views:

17

answers:

0

Running my unit tests i have found that on android i am not receiving the complete atom document while the code works ok for JSE.

The URL is: https://www.googleapis.com/buzz/v1/activities/@me/@consumption?max-results=25

The request headers are: authorization: [OAuth oauth_token="validToken", oauth_consumer_key="anonymous", oauth_version="1.0", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1282297108", oauth_nonce="5247048527864989575", oauth_signature="validSignature"]

The code to make the HTTP request

public static String send( HttpsURLConnection request )
    throws BuzzIOException
{
    StringBuffer response = null;
    try
    {
        // Send request
        request.connect();

        // Read response
        InputStream is = request.getInputStream();
        response = new StringBuffer();
        byte[] b = new byte[4096];
        for ( int n; ( n = is.read( b ) ) != -1; )
        {
            response.append( new String( b, 0, n ) );
        }
    }
    catch ( Exception e )
    {
        throw new BuzzIOException( e );
    }
    //TODO remove debug line, i could set log4j but it is not compatible with android

    try{

        Class<?> clazz = Class.forName("android.util.Log");
        Method androidLog = clazz.getMethod("d", new Class[]{String.class,String.class});
        androidLog.invoke(null, "BuzzIO",response.toString());
    } catch (Exception e) {
        System.out.println(response.toString());
    }

    return response.toString();
}

The response i receive is an invalid atom feed because it gets truncated. the expected length is about 86043 characters but i am getting a response with only 4435