java.io.IOException: Not in GZIP format
at java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:127)
at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:55)
at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:65)
I know for a fact that it is in GZip format, and also that it works on every
server we try it on except on our production server.
Here is the code from the applet that is uploading the file:
URLConnection uc = url.openConnection();
uc.setUseCaches (false);
uc.setDefaultUseCaches(false);
uc.setDoOutput(true);
uc.setDoInput(true);
uc.setRequestProperty("Content-type", "multipart/form-data");
DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new
GZIPOutputStream(uc.getOutputStream())));
...
and on the servlet:
// exception thrown on this line from GZIPInputStream constructor
BufferedInputStream bufIn= new BufferedInputStream(new
GZIPInputStream(request.getInputStream()));
What seems strange is that it all works on many different servers with
different versions of Tomcat and Java, but yet it refuses to work properly
on this one server. Does anyone have a clue what the problem may be?
> Here is the code from the applet that is uploading the file:
>
> URLConnection uc = url.openConnection();
> uc.setUseCaches (false);
> uc.setDefaultUseCaches(false);
> uc.setDoOutput(true);
> uc.setDoInput(true);
> uc.setRequestProperty("Content-type", "multipart/form-data");
> DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new
> GZIPOutputStream(uc.getOutputStream())));
> ...
And where's the code that writes to the stream and then closes it? That
could just as easily be at fault, I suspect.
If you could write a short but complete example of both halves, it would
help enormously.
--
Jon Skeet - <sk...@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
out.write(b,0,i);
out.flush();
out.close();
The HTTP Post is completed with the following code:
DataInputStream server;
server = new DataInputStream(uc.getInputStream());
String line = "";
while ((line = server.readLine())!= null) {
if (line.equals("limit")) done=true;
}
server.close();
Keep in mind as I mentioned, it isn't that the code doesn't work. It is
that it doesn't work on one particular machine. It works fine on the
following configs:
Windows 2000, Tomcat 4.0.3, JDK 1.4.0_1
Redhat 7.3, Tomcat 3.3.1, JDK 1.4.0
Redhat 7.2, Tomcat 4.0.3, JDK 1.3.1
The config of the server on which it doesn't work is:
Redhat 7.2, Tomcat 4.0.3, JDK 1.4.0_1.
The only difference other than that is that the non-working server is an
ensim WEBppliance v3.1. It works fine on this machine when I remove the
GZip portion. It also woks fine sending GZipped data down from the servlet
to the applet. It is only uploading that is a problem. One this
particular server we tried downgrading to JDK 1.3.1 and it didn't solve the
problem.
The problem disappears when I run the applet in the Java Plugin 1.3.1 or
higher. It only occurs when the applet is run in Microsoft's VM for Java,
Netscape 4.7, or Mac MRJ 3.1 (equivalent to java 1.3.1). Again keep in
mind, that all of these browser work fine when communicating with the
servlet on the other 3 servers.
Another important note, I can read the file on the servlet side without
uncmpressing it, and I write it to a file still in gzip form. I can then
successfully unzip it on the server and the file is not corrupted.
I guess the question should be... has anyone seen or experienced these kinds
of inconsistencies using GZip in Java? It seems it is just the one server
where it doesn't work, which leads me to believe it could be a server
problem.
"Jon Skeet" <sk...@pobox.com> wrote in message
news:MPG.17b0c55c5...@dnews.peramon.com...
Aargh - that's probably what's wrong then. You're trying to read
*binary* data as if it were character data - unless I've misunderstood
something. I suspect one reason it may have worked on other platforms
would be due to character encoding differences.
As I said before: a short but complete example of both halves would
help.
> out.flush();
> out.close();
is flush always redundant before a close is all circumstances in all
classes?
--
Available for tutoring, problem solving or contract
programming for $50 US per hour or fixed price.
The Java glossary is at
http://www.mindprod.com/jgloss.html
or http://64.251.89.39/jagg.html
-
canadian mind products, roedy green