By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,782 Members | 1,154 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,782 IT Pros & Developers. It's quick & easy.

Http Compress Request

P: 35
hi ,
I have a doubt .
I have a 5mb file on a server . I am downloading the file from my java application
My application is NOT a web aplication I am using https connection to the sever

My code is something like this

public static void downloadFileSSL(String fileName) {

String urlPath = "";
int portNumber = 443;
try {
String hostName = "";
SSLSocket serSoc = new SSLSocket(hostName,portNumber);

System.out.println("Connection "+serSoc.isConnected());

String fileURL = "/abc/"+fileName;
OutputStream out = serSoc.getOutputStream();
String msg = "GET " + fileURL + " HTTP/1.0\r\n\r\n" ;
byte b[];
try {
b = msg.getBytes("ASCII7");
catch (UnsupportedEncodingException ignored) {
b = msg.getBytes();

BufferedInputStream bin = new BufferedInputStream
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
int ch = 0;
while ((ch = != -1) {

byte[] dataBytes = byteStream.toByteArray();

// Saving into the file
String outFile = "C:\\" + fileName;
FileOutputStream fileOut = new FileOutputStream(outFile);
System.out.println("File Saved Sucessfully.....:"+ fileName);

} catch (IOException e) {
catch (MalformedURLException e) {

This code is working fine but to download that file it take lot of time.
I came to know that we can do https compressed request of that file if that
sever supports that. My server supports that .
So how to make such type of compressed request . what type of parameters
I have to pass with the http header...

Or else if u have any other suggestion please give it
Jan 18 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.