|
|
@ -44,9 +44,11 @@ import java.util.HashSet;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.StringTokenizer;
|
|
|
|
|
|
|
|
import java.util.Map.Entry;
|
|
|
|
import java.util.Map.Entry;
|
|
|
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
import java.util.StringTokenizer;
|
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
|
|
import java.util.concurrent.ConcurrentMap;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
import java.util.zip.GZIPInputStream;
|
|
|
|
import java.util.zip.GZIPInputStream;
|
|
|
|
|
|
|
|
|
|
|
@ -75,12 +77,10 @@ import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
|
|
|
import de.anomic.data.UserDB;
|
|
|
|
import de.anomic.data.UserDB;
|
|
|
|
import de.anomic.search.Switchboard;
|
|
|
|
import de.anomic.search.Switchboard;
|
|
|
|
import de.anomic.server.serverCore;
|
|
|
|
import de.anomic.server.serverCore;
|
|
|
|
|
|
|
|
import de.anomic.server.serverCore.Session;
|
|
|
|
import de.anomic.server.serverHandler;
|
|
|
|
import de.anomic.server.serverHandler;
|
|
|
|
import de.anomic.server.serverObjects;
|
|
|
|
import de.anomic.server.serverObjects;
|
|
|
|
import de.anomic.server.serverSwitch;
|
|
|
|
import de.anomic.server.serverSwitch;
|
|
|
|
import de.anomic.server.serverCore.Session;
|
|
|
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
import java.util.concurrent.ConcurrentMap;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -251,7 +251,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
|
|
|
|
return persistent;
|
|
|
|
return persistent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private boolean handleYaCyHopAuthentication(final RequestHeader header, HashMap<String, Object> prop, Session session) {
|
|
|
|
private boolean handleYaCyHopAuthentication(final RequestHeader header, final HashMap<String, Object> prop, final Session session) {
|
|
|
|
// check if the user has allowed that his/her peer is used for hops
|
|
|
|
// check if the user has allowed that his/her peer is used for hops
|
|
|
|
if (!allowYaCyHop(session)) return false;
|
|
|
|
if (!allowYaCyHop(session)) return false;
|
|
|
|
|
|
|
|
|
|
|
@ -355,7 +355,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
|
|
|
|
public Boolean UNKNOWN(final String arg, final Session session) throws IOException {
|
|
|
|
public Boolean UNKNOWN(final String arg, final Session session) throws IOException {
|
|
|
|
//System.out.println("UNKNOWN " + arg);
|
|
|
|
//System.out.println("UNKNOWN " + arg);
|
|
|
|
|
|
|
|
|
|
|
|
HashMap<String, Object> prop = parseRequestLine(HeaderFramework.METHOD_GET, arg, session);
|
|
|
|
final HashMap<String, Object> prop = parseRequestLine(HeaderFramework.METHOD_GET, arg, session);
|
|
|
|
int pos;
|
|
|
|
int pos;
|
|
|
|
String unknownCommand = null, args = null;
|
|
|
|
String unknownCommand = null, args = null;
|
|
|
|
if ((pos = arg.indexOf(' ')) > 0) {
|
|
|
|
if ((pos = arg.indexOf(' ')) > 0) {
|
|
|
@ -582,7 +582,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
httpVersion = "HTTP/1.0";
|
|
|
|
httpVersion = "HTTP/1.0";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
HashMap<String, Object> prop = new HashMap<String, Object>();
|
|
|
|
final HashMap<String, Object> prop = new HashMap<String, Object>();
|
|
|
|
prop.put(HeaderFramework.CONNECTION_PROP_HTTP_VER, httpVersion);
|
|
|
|
prop.put(HeaderFramework.CONNECTION_PROP_HTTP_VER, httpVersion);
|
|
|
|
|
|
|
|
|
|
|
|
// parse hostname and port
|
|
|
|
// parse hostname and port
|
|
|
@ -620,7 +620,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
|
|
|
|
|
|
|
|
|
|
|
|
// pass to proxy
|
|
|
|
// pass to proxy
|
|
|
|
if (((allowYaCyHop(session)) && (handleYaCyHopAuthentication(header, prop, session))) ||
|
|
|
|
if (((allowYaCyHop(session)) && (handleYaCyHopAuthentication(header, prop, session))) ||
|
|
|
|
((allowProxy(session)) && (this.handleProxyAuthentication(header, prop, session)))) {
|
|
|
|
((allowProxy(session)) && (handleProxyAuthentication(header, prop, session)))) {
|
|
|
|
HTTPDProxyHandler.doConnect(prop, header, session.in, session.out);
|
|
|
|
HTTPDProxyHandler.doConnect(prop, header, session.in, session.out);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// not authorized through firewall blocking (ip does not match filter)
|
|
|
|
// not authorized through firewall blocking (ip does not match filter)
|
|
|
@ -664,7 +664,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
|
|
|
|
// parsing post request bodies with a given length
|
|
|
|
// parsing post request bodies with a given length
|
|
|
|
if (length != -1) {
|
|
|
|
if (length != -1) {
|
|
|
|
buffer = new byte[length];
|
|
|
|
buffer = new byte[length];
|
|
|
|
int bytesRead = in.read(buffer);
|
|
|
|
final int bytesRead = in.read(buffer);
|
|
|
|
assert bytesRead == buffer.length;
|
|
|
|
assert bytesRead == buffer.length;
|
|
|
|
// parsing post request bodies which are gzip content-encoded
|
|
|
|
// parsing post request bodies which are gzip content-encoded
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -808,7 +808,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
|
|
|
|
|
|
|
|
|
|
|
|
final InputStream body = prepareBody(header, in);
|
|
|
|
final InputStream body = prepareBody(header, in);
|
|
|
|
|
|
|
|
|
|
|
|
RequestContext request = new yacyContextRequest(header, body);
|
|
|
|
final RequestContext request = new yacyContextRequest(header, body);
|
|
|
|
|
|
|
|
|
|
|
|
// check information
|
|
|
|
// check information
|
|
|
|
if (!FileUploadBase.isMultipartContent(request)) {
|
|
|
|
if (!FileUploadBase.isMultipartContent(request)) {
|
|
|
@ -816,7 +816,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// check if we have enough memory
|
|
|
|
// check if we have enough memory
|
|
|
|
if (!MemoryControl.request(request.getContentLength() * 3 + 10*1024*1024, false)) {
|
|
|
|
if (request.getContentLength() > 0 && !MemoryControl.request(request.getContentLength() * 3, false)) {
|
|
|
|
throw new IOException("not enough memory available for request. request.getContentLength() = " + request.getContentLength() + ", MemoryControl.available() = " + MemoryControl.available());
|
|
|
|
throw new IOException("not enough memory available for request. request.getContentLength() = " + request.getContentLength() + ", MemoryControl.available() = " + MemoryControl.available());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -826,7 +826,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
final FileUpload upload = new FileUpload(DISK_FILE_ITEM_FACTORY);
|
|
|
|
final FileUpload upload = new FileUpload(DISK_FILE_ITEM_FACTORY);
|
|
|
|
items = upload.parseRequest(request);
|
|
|
|
items = upload.parseRequest(request);
|
|
|
|
} catch (FileUploadException e) {
|
|
|
|
} catch (final FileUploadException e) {
|
|
|
|
throw new IOException("FileUploadException " + e.getMessage());
|
|
|
|
throw new IOException("FileUploadException " + e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -913,7 +913,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
// @Override
|
|
|
|
// @Override
|
|
|
|
public InputStream getInputStream() throws IOException {
|
|
|
|
public InputStream getInputStream() throws IOException {
|
|
|
|
return inStream;
|
|
|
|
return this.inStream;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|