HttpGet problem with Chunked encoding

by m5p3nc3r » Thu, 05 Mar 2009 11:46:33 GMT


Sponsored Links
 Hi Guys

I am having issues retrieving the contents of a chunk encoded web
page. all pages that I try to retrieve throw:
  org.apache.http.MalformedChunkCodingException: Chunked stream ended
unexpectedly

If I retrieve a page with no chunk encoding, the code works fine.


HttpClient httpClient=new DefaultHttpClient();
HttpGet httpGet=new HttpGet(url);
ResponseHandler<String> rh=new BasicResponseHandler();
String response=httpClient.execute(httpGet,rh);

This will work with www.nds.com (no chunk encoding)
but fail with www.google.co.uk (chunk encoding)

Now, I am assuming this is a problem with the apache httpclient
library, but wanted to know if anyone else has seen this problem and
if there is a way of working around it in the current release.

I am using android-sdk-linux_x86-1.1_r1

Regards

Matt

--~--~---------~--~----~------------~-------~--~----~



HttpGet problem with Chunked encoding

by m5p3nc3r » Sat, 07 Mar 2009 01:48:01 GMT


 Sorry for replying to my own post, but it seems that this is a problem
with the version of httpclient/httpcore that is installed with r1.1 of
the SDK.

If I download the latest verison: Core 4.0 and Client 4.0-Beta2,
everything works fine on my Linux desktop.  There is a line in the
release note of Core 4.0:

* [HTTPCORE-175] Chunk decoders no longer accept truncated chunks as
valid input.
  Contributed by Oleg Kalnichevski <olegk at apache.org>

That makes me think this has been fixed in that version.

So my question to the group are:
1, How do I tell what version of libraries are installed on the
system?
2, Is it possible for me to upgrade libraries on the system?  If so,
how?
3, If I have to wait for the libraries to be upgraded, is there a
release schedule I can track anywhere?

Cheers

Matt



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


HttpGet problem with Chunked encoding

by Mark Murphy » Sat, 07 Mar 2009 02:10:00 GMT


 


Not easily.

The source code for Apache HttpClient is integrated into the overall
Android git repo system:

 http://android.git.kernel.org/?p=platform/external/apache-http.git ;a=summary

They just imported the source code, without any sort of RELEASE file.
The quick peek I took at some of the commit log entries does not
indicate which version they have.

On the other hand, since the source is there, you can probably track
major changes by looking for classes introduced in a release. So, if
HttpClient 4.0 added some class, and HttpClient-in-Android is missing
said class, then HttpClient-in-Android isn't on 4.0.

Anybody know a good way to discern which HttpClient is in git?


It is conceivable, though unlikely, that an in-APK edition of HttpClient
would supercede the system libraries.

If you are willing to build your own firmware, you can try replacing
HttpClient, but you might have to make changes to any other code that
uses the older version, if there are API differences, etc.


That I can't help you on...

Please file your problem, and the suggestion of the HttpClient 4.0
upgrade, in  http://b.android.com , if you haven't already.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 

Android Training on the Ranch! -- Mar 16-20, 2009
 http://www.bignerdranch.com/schedule.shtml 

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Android Video Streaming : Only Audio is playing

Hi

I 've set Wowza streaming server to stream mp4 videos to Android
phones. Android phone can play the RTSP stream successfully but here
It only plays audio of the file not the video.

If required I can also provide the source code for the same.


- Regards Anil

-- 

2. classes

Hey Guys,

Is it possible to create another classes object in a class in android.

*I am tryin to do the following:*

/*
 * Copyright (C) 2009 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.example.hellojni;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;


public class HelloJni extends Activity
{
    private samplefile obj123;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        obj123.set123(/*"hello yaar"*/);
        /* Create a TextView and set its content.
         * the text is retrieved by calling a native
         * function.
         */
        TextView  tv = new TextView(this);
        //tv.setText( stringFromJNI() );
        tv.setText( obj123.get123() );
        setContentView(tv);
    }

    /* A native method that is implemented by the
     * 'hello-jni' native library, which is packaged
     * with this application.
     */
    public native String  stringFromJNI();

    /* This is another native method declaration that is *not*
     * implemented by 'hello-jni'. This is simply to show that
     * you can declare as many native methods in your Java code
     * as you want, their implementation is searched in the
     * currently loaded native libraries only the first time
     * you call them.
     *
     * Trying to call this function will result in a
     * java.lang.UnsatisfiedLinkError exception !
     */
    public native String  unimplementedStringFromJNI();

    /* this is used to load the 'hello-jni' library on application
     * startup. The library has already been unpacked into
     * /data/data/com.example.HelloJni/lib/libhello-jni.so at
     * installation time by the package manager.
     */
    static {
        System.loadLibrary("hello-jni");
    }
}


*And, samplefile.java(which is in the same package i.e com.example.hellojni)
looks like:*

package com.example.hellojni;

public class samplefile{
    private String abc;
    public samplefile()
    {
        abc=null;
    }
    public void set123(/*String fgh*/)
    {
        abc="fgh";
    }
    public String get123()
    {
        return abc;
    }
}


But this code would just not run and gives an exception of the group:

W/dalvikvm(  950): threadid=3: thread exiting with uncaught exception
(group=0x4001b180)

Why is this happening? This is something very basic which I am trying to do.
And I think I am making some very silly mistake. Do I need to make any
changes in AndroidManifest.xml for the class samplefile and its file
samplefile.java.

What am I missing? Please guide me guys.

Thanks,

Abhyudai

-- 

3. About the testing of Bluetooth

4. Field Test parameters

5. Windows 7 Android Plugin in Eclipse doesn't show.

6. How to attach sources to android.jar?

7. How to access the external database using the android