Read stream error
Hi, I am working in a little proxy server,
and I have no response to some internet sites, but it's working well for almost all sites.
Please, if anybody already this error, tell me what is wrong with my code.
Sorry for my English.
Thanks.
run :
java Teste www.google.com.br /
(works well)
run :
java Teste br.i1.yimg.com /br/yimg.com/i/br/homepage/iag2.gif
(in this case not work, have no response)
import java.io.*;
import java.net.*;
publicclass Teste{
publicstaticvoid main(String args[])throws Exception{
String CRLF2 ="\r\n\r\n";
String LF2="\n\n";
String CR2="\r\r";
String url =new String("");
String header =new String("");
byte[] oneByte;
oneByte =newbyte[1];
url = args[1];
Socket s =new Socket(args[0], 80);
DataOutputStream dos =new DataOutputStream(s.getOutputStream());
DataInputStream dis =new DataInputStream(s.getInputStream());
dos.writeBytes("GET "+url+" HTTP/1.0\r\n" +
"Host: "+args[0]+"\r\n\r\n");
dos.flush();
while (dis.read(oneByte) != -1)
{
header += (new String(oneByte,"ISO-8859-1"));
if (header.endsWith(CRLF2) || header.endsWith(LF2) ||
header.endsWith(CR2)){
break;
}
}
System.out.println(header);
dis.close();
dos.close();
s.close();
}
}

