I changed to BufferedReader after i head problem as i read in the
internet it
will solve the problem but it did not


On Feb 15, 5:56 pm, Kostya Vasilyev <[email protected]> wrote:
> To add my $0.02 to everything Daniel wrote --
>
> -- why use BufferedHttpEntity?
>
> http://developer.android.com/reference/org/apache/http/entity/Buffere...
>
> > A wrapping entity that buffers it content if necessary. The buffered
> > entity is always repeatable. If the wrapped entity is repeatable
> > itself, calls are passed through. If the wrapped entity is not
> > repeatable, the content is read into a buffer once and provided from
> > there as often as required.
>
> I don't see anything in the posted snippet that would require a
> repeatable entity (i.e. rewinding the stream and reading the same data
> again).
>
> The underlying entity is most likely not repeatable, so all this does is
> forces unnecessary in-memory buffering. Perhaps there is a limit to this
> buffer?
>
> -- Kostya
>
> On 02/15/2012 07:37 PM, Daniel Drozdzewski wrote:
>
>
>
>
>
>
>
> > It is worth examining few things about your entity:
>
> > - is it streaming?
> > - is it chunked?
> > - get it length..
>
> > All of those are method calls on HttpEntity.
>
> > Also it is worth checking the headers of your request. If the
> > requested file is big, it is most likely that it will get chunked by
> > the web server. In such case, your client will need some extra logic
> > to receive the whole chunked file.
> > I *presume* that chunked response mean that getContentLength() returns
> > the length of each chunk that is ready to be received.
>
> > For more info, read some HTTP 1.1 spec:
> >http://sharovatov.wordpress.com/2009/04/30/http-chunked-encoding/
>
> > Daniel
>
> > On 15 February 2012 14:38, limelect<[email protected]>  wrote:
> >> I have this part in a service (or Thread same problem ) to load a file
> >> greater then 400000 char;
> >> almost 1/2 a mega char.
> >> Some times it load much less not consistent.
> >> How to debug it or make adjustment.
> >> Same program download jpg (with modifications) of 30k without a
> >> problem.
>
> >>     StringBuilder downloadFile(String url) {
> >>         final int IO_BUFFER_SIZE = 4 * 1024;
>
> >>         // AndroidHttpClient is not allowed to be used from the main
> >> thread
> >> //        final HttpClient client = (mode == Mode.NO_ASYNC_TASK) ? new
> >> DefaultHttpClient() :
> >>             final HttpClient client = (mode == Mode.CORRECT) ? new
> >> DefaultHttpClient() :
> >>                 AndroidHttpClient.newInstance("Android");
> >>          final HttpGet getRequest = new HttpGet(url);
> >>         try {
> >>             HttpResponse response = client.execute(getRequest);
> >>             final int statusCode =
> >> response.getStatusLine().getStatusCode();
> >>             if (statusCode != HttpStatus.SC_OK) {
> >>                 Log.e("WindGraph", "Error " + statusCode +
> >>                         " while retrieving file from " + url);
> >>                 return null;
> >>             }
> >>             final HttpEntity entity = response.getEntity();
> >>             BufferedHttpEntity bufHttpEntity = new
> >> BufferedHttpEntity(entity);
> >>              if (entity != null) {
> >>                 InputStream inputStream = null;
> >>                 try {
>
> >>                         inputStream = bufHttpEntity.getContent();
> >>>>>>>>>>>>> This is where content fails some time !!!!!!!!!!!!!!!!!!!!!!!!1
> >>                     Log.d("WindGraph","Content size  "
> >> +Integer.toString( (int) bufHttpEntity.getContentLength()));
>
> >> --
> >> You received this message because you are subscribed to the Google
> >> Groups "Android Developers" group.
> >> To post to this group, send email to [email protected]
> >> To unsubscribe from this group, send email to
> >> [email protected]
> >> For more options, visit this group at
> >>http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to