Avoiding conversions of bytes received through HTTP connection
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Filip_Filipov
Posted On:   Monday, August 12, 2002 07:06 AM

Hi, i develop an applet for previewing images genereted on web server through an asp page by the Response.BinaryWrite method. I download the image data by an URLConnection object with the help of BufferedInputStream instance.Unfortunately the createImage(byte[]) from the Toolkit does not create the image after passing the byte array. I even tried the Toolkit.createImage(url) but i have the same result.I checked the size of the file generated on the server and the one being downloaded and they are one and the same,which means that the file is defenately downloaded. The content type of the HTTP response is set to image/jpeg as the file being generated is a jpeg file. During the debugging i noticed that the underlying stream in the URLConnection object has a buffe   More>>

Hi, i develop an applet for previewing images genereted on web server through an asp page by the Response.BinaryWrite method. I download the image data by an URLConnection object with the help of BufferedInputStream instance.Unfortunately the createImage(byte[]) from the Toolkit does not create the image after passing the byte array. I even tried the Toolkit.createImage(url) but i have the same result.I checked the size of the file generated on the server and the one being downloaded and they are one and the same,which means that the file is defenately downloaded. The content type of the HTTP response is set to image/jpeg as the file being generated is a jpeg file.


During the debugging i noticed that the underlying stream in the URLConnection object has a buffer which holds completely different data from what i receive in the allocated array. This smells like there is some byte to char conversion going on between the reads from the underlying stream object and the one i've instantiated.The code page used by default is Cp1252 in the sun.io.NetworkClient instance,which is hold by the URLConnection object.


I would like to know if there is some way to avoid this conversion,as well as other approaches for solving this problem.


Thank you in advance

   <<Less
About | Sitemap | Contact