Ok daniel one small suggestion

After playing with wireshark i added to the software
Log.e("WindGraph","response  "+response.getAllHeaders()[5]);
and i see Content-Length: >>> LES then needed
Am i to deduce that is the SERVER fault???
Thank




On Feb 15, 6:53 pm, limelect <[email protected]> wrote:
> getContentLength() returne less then needed size much less
> I know as a pro this one is of those ones
> Thanks in any case it will take all my effort
> P.S if i parse wrongly the page i reload it again
> so i do it 6 times
> So i see every time it get more from the page
> 130k 150k 200k (not round numbers) randomly then after a wile it gets
> ok and then after
> a few minutes ( i download every 10 seconds) it breaks down again and
> so on
> i wander if it is not time out of http ? Or memory ?
>
> On Feb 15, 6:42 pm, Daniel Drozdzewski <[email protected]>
> wrote:
>
>
>
>
>
>
>
> > What does getContentLength() return for the failing requests?
>
> > Other idea is to look into HTTP response and all of its headers and the 
> > body.
>
> > Run your code from within the emulator and use Wireshark to peep into
> > the HTTP requests and responses.
>
> > On 15 February 2012 16:28, limelect <[email protected]> wrote:
>
> > > Well i added as daniel advice this pies of cod
>
> > >           Log.d("WindGraph","Chunk ?  "+
> > > entity.isChunked());<<<<<<<<<<<
> > >            BufferedHttpEntity bufHttpEntity = new
> > > BufferedHttpEntity(entity);
> > >             if (entity != null) {
> > >                InputStream inputStream = null;
> > >                try {
> > >                //      entity.getContentLength()
> > > //                    inputStream = entity.getContent();
> > >                        inputStream = bufHttpEntity.getContent();
> > >                        Log.d("WindGraph","Chunk 2 ?  "+
> > > bufHttpEntity.isChunked());<<<<<<<<<<<<<<<
>
> > > both show FALSE (no chunk) when the down load fails
> > > Any idea what to look for?
>
> > > On Feb 15, 6:02 pm, limelect <[email protected]> wrote:
> > >> 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
>
> > --
> > Daniel Drozdzewski

-- 
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