parent
b461a27abb
commit
84167adb49
@ -1,157 +0,0 @@
|
||||
package net.yacy.interaction;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.StringReader;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import net.yacy.cora.document.encoding.ASCII;
|
||||
import net.yacy.cora.document.id.DigestURL;
|
||||
import net.yacy.cora.protocol.ClientIdentification;
|
||||
import net.yacy.cora.protocol.Domains;
|
||||
import net.yacy.cora.protocol.RequestHeader;
|
||||
import net.yacy.cora.protocol.http.HTTPClient;
|
||||
import net.yacy.cora.util.ConcurrentLog;
|
||||
import net.yacy.search.Switchboard;
|
||||
import net.yacy.server.http.ServerSideIncludes;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
|
||||
public class AugmentHtmlStream {
|
||||
|
||||
static RequestHeader globalrequestHeader;
|
||||
|
||||
/**
|
||||
* send web page to external REFLECT web service
|
||||
*
|
||||
* @return the web page with integrated REFLECT elements
|
||||
*/
|
||||
private static String processExternal(String url, String fieldname, String data) throws IOException {
|
||||
final HTTPClient client = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent);
|
||||
try {
|
||||
StringBuilder postdata = new StringBuilder();
|
||||
postdata.append(fieldname);
|
||||
postdata.append('=');
|
||||
postdata.append(URLEncoder.encode(data, "UTF-8"));
|
||||
InputStream in = new ByteArrayInputStream(postdata.toString()
|
||||
.getBytes());
|
||||
byte[] result = client.POSTbytes(url, in, postdata.length());
|
||||
if (result != null) {
|
||||
return new String(result);
|
||||
}
|
||||
} finally {
|
||||
client.finish();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String loadInternal(String path, RequestHeader requestHeader) {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
String realmProp = requestHeader.get(RequestHeader.AUTHORIZATION);
|
||||
ServerSideIncludes.writeContent(path, buffer, realmProp, Domains.LOCALHOST, requestHeader); // TODO: ip
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* add DOCTYPE if necessary
|
||||
*
|
||||
* @return the web page with a leading DOCTYPE definition
|
||||
*/
|
||||
private static String processAddDoctype(String data) {
|
||||
|
||||
String result = data;
|
||||
|
||||
BufferedReader reader = new BufferedReader(new StringReader(data));
|
||||
|
||||
try {
|
||||
String firstline = reader.readLine();
|
||||
|
||||
if (firstline != null) {
|
||||
if (!firstline.startsWith("<!DOCTYPE")) {
|
||||
result = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n"
|
||||
+ data;
|
||||
}
|
||||
}
|
||||
} catch (final IOException e1) {
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
public static StringBuilder process(StringBuilder data, DigestURL url, RequestHeader requestHeader) {
|
||||
|
||||
String action = requestHeader.get("YACYACTION");
|
||||
requestHeader.remove("YACYACTION");
|
||||
|
||||
globalrequestHeader = requestHeader;
|
||||
|
||||
Switchboard sb = Switchboard.getSwitchboard();
|
||||
|
||||
boolean augmented = false;
|
||||
|
||||
try {
|
||||
ConcurrentLog.info("AUGMENTATION", url.getName());
|
||||
} catch (final IOException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
String Doc = data.toString();
|
||||
|
||||
// Send document to REFLECT (http://www.reflect.ws/REST_API.html)
|
||||
if (sb.getConfigBool("augmentation.reflect", false) == true) {
|
||||
try {
|
||||
|
||||
Doc = processExternal("http://reflect.ws/REST/GetHTML", "document", Doc);
|
||||
ConcurrentLog.info("AUGMENTATION", "reflected " + url);
|
||||
augmented = true;
|
||||
} catch (final Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Add DOCTYPE if not present.
|
||||
// This is required for IE to render position:absolute correctly.
|
||||
|
||||
if (sb.getConfigBool("augmentation.addDoctype", false) == true) {
|
||||
Doc = processAddDoctype(Doc);
|
||||
augmented = true;
|
||||
}
|
||||
|
||||
|
||||
if (sb.getConfigBool("augmentation.reparse", false) == true) {
|
||||
|
||||
org.jsoup.nodes.Document d = Jsoup.parse(Doc);
|
||||
|
||||
d.title ("yacy - "+d.title());
|
||||
|
||||
if (sb.getConfigBool("interaction.overlayinteraction.enabled", false) == true) {
|
||||
|
||||
d.head().append (loadInternal("env/templates/jqueryheader.template", requestHeader));
|
||||
d.head().append ("<script type='text/javascript'>"+loadInternal("interaction_elements/interaction.js", requestHeader)+"</script>");
|
||||
d.head().append ("<script type='text/javascript'>"+loadInternal("interaction_elements/interaction_metadata.js", requestHeader)+"</script>");
|
||||
|
||||
|
||||
d.body().append (loadInternal("interaction_elements/OverlayInteraction.html?action="+action+"&urlhash="+ ASCII.String(url.hash()) +"&url="+url.toNormalform(false), requestHeader));
|
||||
d.body().append (loadInternal("interaction_elements/Footer.html?action="+action+"&urlhash="+ ASCII.String(url.hash()) +"&url="+url.toNormalform(false), requestHeader));
|
||||
|
||||
}
|
||||
|
||||
Doc = d.html();
|
||||
|
||||
augmented = true;
|
||||
}
|
||||
|
||||
|
||||
if (augmented) {
|
||||
return (new StringBuilder(Doc));
|
||||
}
|
||||
return (data);
|
||||
}
|
||||
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
package net.yacy.server.http;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FilterOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import net.yacy.cora.document.id.DigestURL;
|
||||
import net.yacy.cora.protocol.RequestHeader;
|
||||
import net.yacy.interaction.AugmentHtmlStream;
|
||||
|
||||
public class AugmentedHtmlStream extends FilterOutputStream {
|
||||
private final Writer out;
|
||||
private final ByteArrayOutputStream buffer;
|
||||
private final Charset charset;
|
||||
private final DigestURL url;
|
||||
private final String urls;
|
||||
private final RequestHeader requestHeader;
|
||||
|
||||
public AugmentedHtmlStream(OutputStream out, Charset charset, DigestURL url, RequestHeader requestHeader) {
|
||||
super(out);
|
||||
this.out = new BufferedWriter(new OutputStreamWriter(out, charset));
|
||||
this.buffer = new ByteArrayOutputStream();
|
||||
this.charset = charset;
|
||||
this.url = url;
|
||||
this.urls = this.url.toNormalform(false);
|
||||
this.requestHeader = requestHeader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
this.buffer.write(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
this.buffer.write(b, off, len);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
StringBuilder b = new StringBuilder(this.buffer.toString(this.charset.name()));
|
||||
b = process(b);
|
||||
this.out.write(b.toString());
|
||||
this.out.close();
|
||||
}
|
||||
|
||||
public StringBuilder process(StringBuilder data) {
|
||||
if (this.urls.contains("StringBuilder/")) {
|
||||
return data;
|
||||
}
|
||||
return AugmentHtmlStream.process(data, this.url, this.requestHeader);
|
||||
}
|
||||
|
||||
public static boolean supportsMime(String mime) {
|
||||
// System.out.println("mime" +mime);
|
||||
return mime.split(";")[0].equals("text/html");
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,99 +0,0 @@
|
||||
// ServerSideIncludes.java
|
||||
// -----------------------------
|
||||
// (C) 2007 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany
|
||||
// first published 26.06.2007 on http://yacy.net
|
||||
//
|
||||
// This is a part of YaCy, a peer-to-peer based web search engine
|
||||
//
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
// $LastChangedBy$
|
||||
//
|
||||
// LICENSE
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package net.yacy.server.http;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.yacy.cora.document.encoding.ASCII;
|
||||
import net.yacy.cora.protocol.HeaderFramework;
|
||||
import net.yacy.cora.protocol.RequestHeader;
|
||||
import net.yacy.cora.util.ByteBuffer;
|
||||
|
||||
|
||||
public class ServerSideIncludes {
|
||||
|
||||
public static void writeSSI(final ByteBuffer in, final OutputStream out, final String authorization, final String requesthost, final RequestHeader requestHeader) throws IOException {
|
||||
writeSSI(in, 0, out, authorization, requesthost, requestHeader);
|
||||
}
|
||||
|
||||
private static void writeSSI(final ByteBuffer in, int off, final OutputStream out, final String authorization, final String requesthost, final RequestHeader requestHeader) throws IOException {
|
||||
int p = in.indexOf(ASCII.getBytes("<!--#"), off);
|
||||
int q;
|
||||
while (p >= 0) {
|
||||
q = in.indexOf(ASCII.getBytes("-->"), p + 10);
|
||||
if (out instanceof ChunkedOutputStream) {
|
||||
((ChunkedOutputStream) out).write(in, off, p - off);
|
||||
} else {
|
||||
out.write(in.getBytes(off, p - off));
|
||||
}
|
||||
parseSSI(in, p, out, authorization, requesthost, requestHeader);
|
||||
off = q + 3;
|
||||
p = in.indexOf(ASCII.getBytes("<!--#"), off);
|
||||
}
|
||||
if (out instanceof ChunkedOutputStream) {
|
||||
((ChunkedOutputStream) out).write(in, off, in.length() - off);
|
||||
} else {
|
||||
out.write(in.getBytes(off, in.length() - off));
|
||||
}
|
||||
}
|
||||
|
||||
private static void parseSSI(final ByteBuffer in, final int off, final OutputStream out, final String authorization, final String requesthost, final RequestHeader requestHeader) {
|
||||
if (in.startsWith(ASCII.getBytes("<!--#include virtual=\""), off)) {
|
||||
final int q = in.indexOf(ASCII.getBytes("\""), off + 22);
|
||||
if (q > 0) {
|
||||
final String path = in.toString(off + 22, q - off - 22);
|
||||
writeContent(path, out, authorization, requesthost, requestHeader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeContent(String path, final OutputStream out, final String authorization, final String requesthost, final RequestHeader requestHeader) {
|
||||
// check if there are arguments in path string
|
||||
String args = "";
|
||||
final int argpos = path.indexOf('?');
|
||||
if (argpos > 0) {
|
||||
args = path.substring(argpos + 1);
|
||||
path = path.substring(0, argpos);
|
||||
}
|
||||
|
||||
// set up virtual connection properties to call httpdFileHander.doGet()
|
||||
final HashMap<String, Object> conProp = new HashMap<String, Object>();
|
||||
final RequestHeader header = new RequestHeader(HTTPDemon.reverseMappingCache);
|
||||
conProp.put(HeaderFramework.CONNECTION_PROP_METHOD, HeaderFramework.METHOD_GET);
|
||||
conProp.put(HeaderFramework.CONNECTION_PROP_PATH, path);
|
||||
conProp.put(HeaderFramework.CONNECTION_PROP_ARGS, args);
|
||||
conProp.put(HeaderFramework.CONNECTION_PROP_HTTP_VER, HeaderFramework.HTTP_VERSION_0_9);
|
||||
conProp.put(HeaderFramework.CONNECTION_PROP_CLIENTIP, requesthost);
|
||||
header.put(RequestHeader.AUTHORIZATION, authorization);
|
||||
if (requestHeader.containsKey(RequestHeader.COOKIE)) header.put(RequestHeader.COOKIE, requestHeader.get(RequestHeader.COOKIE));
|
||||
header.put(RequestHeader.REFERER, requestHeader.get(RequestHeader.REFERER));
|
||||
HTTPDFileHandler.doGet(conProp, header, out);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,212 +0,0 @@
|
||||
//serverCoreSocket.java
|
||||
//-------------------------------------
|
||||
//part of YACY
|
||||
//
|
||||
//(C) 2006 by Martin Thelian
|
||||
//
|
||||
//last change: $LastChangedDate$ by $LastChangedBy$
|
||||
//Revision: $LastChangedRevision$
|
||||
//
|
||||
//This program is free software; you can redistribute it and/or modify
|
||||
//it under the terms of the GNU General Public License as published by
|
||||
//the Free Software Foundation; either version 2 of the License, or
|
||||
//(at your option) any later version.
|
||||
//
|
||||
//This program is distributed in the hope that it will be useful,
|
||||
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
//GNU General Public License for more details.
|
||||
//
|
||||
//You should have received a copy of the GNU General Public License
|
||||
//along with this program; if not, write to the Free Software
|
||||
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package net.yacy.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PushbackInputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.SocketException;
|
||||
import java.nio.channels.SocketChannel;
|
||||
|
||||
public class serverCoreSocket extends Socket {
|
||||
|
||||
private PushbackInputStream input = null;
|
||||
private Socket sock = null;
|
||||
private boolean isSSL = false;
|
||||
private String sslType = null;
|
||||
|
||||
public serverCoreSocket(final Socket sock) throws IOException {
|
||||
this.sock = sock;
|
||||
|
||||
// determine the socket type
|
||||
detectSSL();
|
||||
}
|
||||
|
||||
public boolean isSSL() {
|
||||
return this.isSSL;
|
||||
}
|
||||
|
||||
public String getProtocol() {
|
||||
return this.sslType;
|
||||
}
|
||||
|
||||
private void detectSSL() throws IOException {
|
||||
final InputStream in = getInputStream();
|
||||
|
||||
// read the first 5 bytes to determine the protocol type
|
||||
final byte[] preRead = new byte[5];
|
||||
int read, count = 0;
|
||||
while ((count < preRead.length) && ((read = in.read()) != -1)) {
|
||||
preRead[count] = (byte) read;
|
||||
count++;
|
||||
}
|
||||
if (count < preRead.length) {
|
||||
((PushbackInputStream) in).unread(preRead,0,count);
|
||||
return;
|
||||
}
|
||||
|
||||
int idx = 0;
|
||||
if ((preRead[0] & 0xFF) == 22) {
|
||||
// we have detected the ContentType field.
|
||||
// 22 means "handshake"
|
||||
idx = 1;
|
||||
} else {
|
||||
// SSL messages have two preceding bytes
|
||||
// byte nr 3 specifies the handshake type
|
||||
// 3 means "ClientHello"
|
||||
final int handshakeType = preRead[2] & 0x00FF;
|
||||
if (handshakeType == 1) this.isSSL = true;
|
||||
idx = 3;
|
||||
}
|
||||
|
||||
// determine the protocol version
|
||||
if (preRead[idx] == 3 && (preRead[idx+1] >= 0 && preRead[idx+1] <= 2)) {
|
||||
switch (preRead[idx+1]) {
|
||||
case 0:
|
||||
this.sslType = "SSL_3";
|
||||
break;
|
||||
case 1:
|
||||
this.sslType = "TLS_1";
|
||||
break;
|
||||
case 2:
|
||||
this.sslType = "TLS_1_1";
|
||||
break;
|
||||
default:
|
||||
this.sslType = "SSL_3";
|
||||
break;
|
||||
}
|
||||
this.isSSL = true;
|
||||
//} else {
|
||||
// maybe SSL_2, but we can not be sure
|
||||
}
|
||||
|
||||
// unread pre read bytes
|
||||
((PushbackInputStream) in).unread(preRead);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetAddress getInetAddress() {
|
||||
return this.sock.getInetAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetAddress getLocalAddress() {
|
||||
return this.sock.getLocalAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort() {
|
||||
return this.sock.getPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLocalPort() {
|
||||
return this.sock.getLocalPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocketAddress getRemoteSocketAddress() {
|
||||
return this.sock.getRemoteSocketAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocketAddress getLocalSocketAddress() {
|
||||
return this.sock.getLocalSocketAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocketChannel getChannel() {
|
||||
return this.sock.getChannel();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
if (this.input == null) {
|
||||
this.input = new PushbackInputStream(this.sock.getInputStream(),100);
|
||||
}
|
||||
return this.input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getOutputStream() throws IOException {
|
||||
return this.sock.getOutputStream();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public synchronized void close() throws IOException {
|
||||
this.sock.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdownInput() throws IOException {
|
||||
this.sock.shutdownInput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdownOutput() throws IOException {
|
||||
this.sock.shutdownOutput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.sock.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
return this.sock.isConnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBound() {
|
||||
return this.sock.isBound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClosed() {
|
||||
return this.sock.isClosed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInputShutdown() {
|
||||
return this.sock.isInputShutdown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOutputShutdown() {
|
||||
return this.sock.isOutputShutdown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void setSoTimeout(final int timeout) throws SocketException {
|
||||
this.sock.setSoTimeout(timeout);
|
||||
}
|
||||
|
||||
}
|
@ -1,105 +0,0 @@
|
||||
// serverHandler.java
|
||||
// -------------------------------------------
|
||||
// (C) by Michael Peter Christen; mc@yacy.net
|
||||
// first published on http://www.anomic.de
|
||||
// Frankfurt, Germany, 2004
|
||||
// last major change: 05.04.2004
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
/*
|
||||
serverHandler:
|
||||
|
||||
A Generic Server becomes a server for s specific protocol by impementation of
|
||||
a corresponding handler class. The handler class provides methods for each
|
||||
command of the protocol that is implemented.
|
||||
The Handler class is assigned to the serverCore by passing the handlers
|
||||
name to the serverCore upon initialization.
|
||||
Example:
|
||||
serverCore server = new serverCore(port, 1000, 0, false, "ftpdProtocol", null, 0);
|
||||
In this example the protocol handler "ftpdProtocol" is assigned. There a class
|
||||
named ftpdProtocol.java must be implemented, that implements this interface,
|
||||
a serverHandler.
|
||||
Any protocol command can be implemented in either way:
|
||||
|
||||
public String COMMAND(String arg) throws IOException;
|
||||
public InputStream COMMAND(String arg) throws IOException;
|
||||
public void COMMAND(String arg) throws IOException;
|
||||
|
||||
..where COMMAND is the command that had been passed to the server
|
||||
on the terminal connection. The 'arg' argument is the remaining part of
|
||||
the command on the terminal connection.
|
||||
If the handler method returns a NULL value, which is especially
|
||||
the case if the method implements a 'void' return-value method,
|
||||
then the server disconnects the connection.
|
||||
Any other return value (String or an InputStream) is returned to
|
||||
the client on it's own line through the terminal connection.
|
||||
If it is wanted that the server terminates right after submitting
|
||||
a last line, then this can be indicated by prefixing the return
|
||||
value by a '!'-character.
|
||||
|
||||
If one of the command methods throws a IOException, then the
|
||||
server asks the error - method for a return value on the terminal
|
||||
connection.
|
||||
|
||||
The greeting-method is used to request a string that is transmitted
|
||||
to the client as terminal output at the beginning of a connection
|
||||
session.
|
||||
*/
|
||||
|
||||
package net.yacy.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.yacy.server.serverCore.Session;
|
||||
|
||||
|
||||
|
||||
public interface serverHandler {
|
||||
|
||||
// a response line upon connection is send to client
|
||||
// if no response line is wanted, return "" or null
|
||||
public String greeting();
|
||||
|
||||
// return string in case of any error that occurs during communication
|
||||
// is always (but not only) called if an IO-dependent exception occurs.
|
||||
public String error(Throwable e);
|
||||
|
||||
// clone method for the handler prototype
|
||||
// each time a server makes a new connection it clones the hanlder prototype
|
||||
// the clone method does not need to clone every detail of a handler connection,
|
||||
// but only the necessary one for a newly initialized instance
|
||||
public serverHandler clone();
|
||||
|
||||
/**
|
||||
* Instead of using clone this function can be used to reset an existing
|
||||
* handler prototype so that it can e reused
|
||||
*/
|
||||
public void reset();
|
||||
|
||||
/**
|
||||
* Tthis function will be called by the {@link serverCore}.listen() function
|
||||
* if the whole request line is empty and therefore no function of this
|
||||
* serverHandlerClass can be called because of the missing command name
|
||||
*/
|
||||
public Boolean EMPTY(String arg, Session session) throws IOException;
|
||||
|
||||
/**
|
||||
* This function will be called by the {@link serverCore}.listen() function
|
||||
* if no corresponding funktion of the serverHandler class can be
|
||||
* found for the received command.
|
||||
*/
|
||||
public Boolean UNKNOWN(String requestLine, Session session) throws IOException;
|
||||
}
|
Loading…
Reference in new issue