HTTPServer: accepttimeout not needed

Request: fixed charset and gzip bug

git-svn-id: svn://svn.jdownloader.org/jdownloader/trunk@5981 ebf7c1c2-ba36-0410-9fe8-c592906822b4
This commit is contained in:
jiaz 2009-06-02 21:42:03 +00:00
parent 176778e568
commit 3701a56a7b
3 changed files with 28 additions and 28 deletions

View File

@ -1,10 +1,13 @@
import java.io.IOException;
import jd.http.Browser;
public class header {
public static void main(String[] args) {
public static void main(String[] args) throws IOException {
System.out.println(3%3);
}
}

View File

@ -18,6 +18,7 @@ package jd.http.requests;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
@ -473,38 +474,35 @@ public abstract class Request {
long tima = System.currentTimeMillis();
this.htmlCode = read(httpConnection);
readTime = System.currentTimeMillis() - tima;
return htmlCode.toString();
}
public static String read(URLConnectionAdapter con) throws IOException {
BufferedReader rd;
InputStreamReader isr;
InputStream is;
if (con.getHeaderField("Content-Encoding") != null && con.getHeaderField("Content-Encoding").equalsIgnoreCase("gzip")) {
rd = new BufferedReader(new InputStreamReader(new GZIPInputStream(con.getInputStream())));
is = new GZIPInputStream(con.getInputStream());
} else {
String cs = con.getCharset();
if (cs == null) {
rd = new BufferedReader(new InputStreamReader(con.getInputStream()));
} else {
try {
rd = new BufferedReader(new InputStreamReader(con.getInputStream(), cs));
} catch (Exception e) {
jd.controlling.JDLogger.getLogger().log(java.util.logging.Level.SEVERE, "Exception occured", e);
System.err.println(con);
try {
rd = new BufferedReader(new InputStreamReader(con.getInputStream(), cs.replace("-", "")));
} catch (Exception e2) {
rd = new BufferedReader(new InputStreamReader(con.getInputStream()));
}
}
}
is = con.getInputStream();
}
String cs = con.getCharset();
if (cs == null) {
isr = new InputStreamReader(is);
} else {
try {
isr = new InputStreamReader(is, cs);
} catch (Exception e) {
jd.controlling.JDLogger.getLogger().log(java.util.logging.Level.SEVERE, "Could not Handle Charset " + cs, e);
try {
isr = new InputStreamReader(is, cs.replace("-", ""));
} catch (Exception e2) {
jd.controlling.JDLogger.getLogger().log(java.util.logging.Level.SEVERE, "Could not Handle Charset " + cs, e);
isr = new InputStreamReader(is);
}
}
}
rd = new BufferedReader(isr);
String line;
StringBuilder htmlCode = new StringBuilder();
while ((line = rd.readLine()) != null) {
@ -558,7 +556,6 @@ public abstract class Request {
this.htmlCode = htmlCode;
}
public Request toHeadRequest() throws MalformedURLException {
Request ret = new Request(this.getUrl() + "") {
// @Override

View File

@ -44,7 +44,7 @@ public class HttpServer extends Thread {
running = true;
try {
ssocket = new ServerSocket(port);
ssocket.setSoTimeout(1000);
//ssocket.setSoTimeout(1000);
} catch (IOException e) {
JDLogger.exception(e);
}