This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Reading from an URLConnection problem on Netscape 4.7

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I can't come up with a reliable code for reading from an URL connection on a PHP script with an applet running on Netscape 4.7. My code works on other browsers (IE 5, Netscape 6), but not consistently on Netscape 4.7 when my data (which is text/plain) is large : when I call the read() method on my InputStreamReader, Netscape4.7 won't read all the bytes whereas the buffer is large enough. I suspect my PHP script doesn't put the right headers because conn.getContentLength() for example returns -1.
The funny thing is that when I compress my data in the php script (serving a gzip file), the applet reads the output ok using a GZIPInputStream !
My code looks like this :
con = myURL.openConnection();
con.setDoOutput(true);
con.setDoInput(true);
con.setUseCaches(false);
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
con.setRequestProperty("Content-Length", " " + paramStr.length());
DataOutputStream out = new DataOutputStream(con.getOutputStream());
out.writeBytes(paramStr);
out.flush();
out.close();
InputStream in = new DataInputStream(con.getInputStream());
InputStreamReader urlReader = new InputStreamReader(in);
cbuf = new char[large_enough_int];
mylength = urlReader.read(cbuf);
As a result, mylength is less than the number of bytes really available from the ressource !
Many thanks in advance.
 
Why am I so drawn to cherry pie? I can't seem to stop. Save me tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic