improvements to tidy config and header parsing
This commit is contained in:
parent
9b6f1f8ff0
commit
7bf1a7c799
4 changed files with 13 additions and 5 deletions
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
func dependencies {
|
func dependencies {
|
||||||
"https://github.com/TudbuT/tuddylib/raw/master/TuddyLIB.jar" download
|
"https://github.com/TudbuT/tuddylib/raw/master/TuddyLIB.jar" download
|
||||||
"https://github.com/TudbuT/tuddylib/raw/master/TuddyLIB-javadoc.zip" download
|
|
||||||
"https://github.com/TudbuT/isbpl-random-stuff/raw/master/ISBPL.jar" download
|
"https://github.com/TudbuT/isbpl-random-stuff/raw/master/ISBPL.jar" download
|
||||||
"https://github.com/jtidy/jtidy/releases/download/1.0.2-SNAPSHOT/jtidy-1.0.2-SNAPSHOT.jar" download
|
"https://github.com/jtidy/jtidy/releases/download/1.0.2-SNAPSHOT/jtidy-1.0.2-SNAPSHOT.jar" download
|
||||||
"https://github.com/jtidy/jtidy/releases/download/1.0.2-SNAPSHOT/jtidy-1.0.2-SNAPSHOT-sources.jar" download
|
"https://github.com/jtidy/jtidy/releases/download/1.0.2-SNAPSHOT/jtidy-1.0.2-SNAPSHOT-sources.jar" download
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class BrowserContext {
|
||||||
return cache.get(file);
|
return cache.get(file);
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
try {
|
try {
|
||||||
InputStream stream = new FileInputStream(file);
|
InputStream stream = requestCatcher.getClass().getClassLoader().getResourceAsStream(file);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while((i = stream.read()) != -1) {
|
while((i = stream.read()) != -1) {
|
||||||
|
|
|
@ -15,6 +15,15 @@ import de.tudbut.tryumph.util.Bug;
|
||||||
|
|
||||||
public class HTMLParsing {
|
public class HTMLParsing {
|
||||||
private static Tidy tidy = new Tidy();
|
private static Tidy tidy = new Tidy();
|
||||||
|
static {
|
||||||
|
tidy.setIndentContent(true);
|
||||||
|
tidy.setWraplen(150);
|
||||||
|
tidy.setTidyMark(false);
|
||||||
|
tidy.setDropProprietaryTags(false);
|
||||||
|
tidy.setDropProprietaryAttributes(false);
|
||||||
|
tidy.setSpaces(4);
|
||||||
|
tidy.setXHTML(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Element getElementById(Document document, String id) {
|
public static Element getElementById(Document document, String id) {
|
||||||
|
|
|
@ -57,13 +57,13 @@ public class HTTPRequestReader {
|
||||||
assumeCRLF();
|
assumeCRLF();
|
||||||
String header;
|
String header;
|
||||||
while(!(header = readUntilCRLF()).isEmpty()) {
|
while(!(header = readUntilCRLF()).isEmpty()) {
|
||||||
boolean hasParameters = header.indexOf(';') != -1 && header.indexOf('=') != -1;
|
boolean hasParameters = header.indexOf("; ") != -1 && header.indexOf('=') != -1;
|
||||||
String name = header.substring(0, header.indexOf(':'));
|
String name = header.substring(0, header.indexOf(':'));
|
||||||
String value = HTTPUtils.decodeUTF8(header.substring(
|
String value = HTTPUtils.decodeUTF8(header.substring(
|
||||||
header.indexOf(':') + 2,
|
header.indexOf(':') + 2,
|
||||||
hasParameters ? header.indexOf(';') : header.length()
|
hasParameters ? header.indexOf("; ") : header.length()
|
||||||
));
|
));
|
||||||
String parameters = hasParameters ? header.substring(header.indexOf(';') + 2) : "";
|
String parameters = hasParameters ? header.substring(header.indexOf("; ") + 2) : "";
|
||||||
HashMap<String, String> parameterMap = splitParameters(parameters);
|
HashMap<String, String> parameterMap = splitParameters(parameters);
|
||||||
// Handle cookies
|
// Handle cookies
|
||||||
if(name.equals("Cookie")) {
|
if(name.equals("Cookie")) {
|
||||||
|
|
Loading…
Reference in a new issue