You Are Here:

Community: Developer Discussion Boards

#1 Old Nokia 3650,HttpConnection.getLeng th()==0,Problem? - 2003-03-03, 14:48

Join Date: Mar 2003
Posts: 5
laux117
Offline
Registered User
hello,all,
I find that HttpConnection used in 3650 may bring a problem that although the server has pushed data to here,but getLength() is zero,but in 7650,it is not zero,but a correct Integer,is it a serious problem?then how to read my data from server? thanks much.
the code is here:

HttpConnection connection = (HttpConnection)Connector.open(uri);

connection.setRequestMethod(HttpConnection.POST);
connection.setRequestProperty("User-Agent",ua);
connection.setRequestProperty("Content-Language",locale);
connection.setRequestProperty("Content-Length",bytes.length+" ");

outputStream = connection.openOutputStream();
outputStream.write(bytes);
outputStream.flush();

inputStream = connection.openInputStream();
int len = (int)connection.getLength();
//!!!!here len ==-1 in Nokia 3650!
Reply With Quote

#2 Old RE: Nokia 3650,HttpConnection.getLe ng th()==0,Problem? - 2003-03-03, 14:50

Join Date: Mar 2003
Posts: 5
laux117
Offline
Registered User
I am sorry,HttpConnection.getLeng th()==-1,not zero.
Reply With Quote

#3 Old 2003-04-10, 01:13

Join Date: Mar 2003
Posts: 7
sorrent
Offline
Registered User
We have seen the same problem; it looks most of the header info is being stripped out. No word from Nokia yet on a solution. Here's how you can read the stream without knowing the length:

int read = 0;
int offset = 0;
byte tmp[] = new byte[8196];
while (true) {
read = is.read(tmp, offset, 8196 - offset); if (read < 0)
break;
offset += read;
}
buf = new byte[offset];
System.arraycopy(tmp, 0, buf, 0, offset);
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia