- SSIs may now refer to servlets, not only files - calling a servlet, the servlet/SSI engine is called recursively - SSIs now work also for non-chunked-encoding supporting clients This will support the new search page functionality, to show search results dynamically without using javascript. To test this method, a test page has been added http://localhost:8080/ssitest.html ..calls dynamicalls 3 servlets, which produce some delays during their execution please verify that you can see the result step-by-step on your browser To implement this feature, some refactoring had been taken place, mostly code had been made static and will execute faster. git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4037 6c8d7289-2bf4-0310-a012-ef5d649a1542pull/1/head
parent
c8e5a4a6b7
commit
24e25e1141
@ -0,0 +1,4 @@
|
||||
<p>
|
||||
testservlet ok nach #[delay]# millisekunden Pause.<br>
|
||||
start = #[start]#, stop = #[stop]#
|
||||
</p>
|
@ -0,0 +1,55 @@
|
||||
// ssitestservlet.java
|
||||
// --------------------
|
||||
// (C) 2007 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany
|
||||
// first published 09.08.2007 on http://yacy.net
|
||||
//
|
||||
// This is a part of YaCy, a peer-to-peer based web search engine
|
||||
//
|
||||
// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $
|
||||
// $LastChangedRevision: 1986 $
|
||||
// $LastChangedBy: orbiter $
|
||||
//
|
||||
// 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
|
||||
|
||||
import de.anomic.http.httpHeader;
|
||||
import de.anomic.server.serverObjects;
|
||||
import de.anomic.server.serverSwitch;
|
||||
|
||||
public class ssitestservlet {
|
||||
|
||||
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
|
||||
|
||||
//plasmaSwitchboard sb = (plasmaSwitchboard) env;
|
||||
serverObjects prop = new serverObjects();
|
||||
int delay = 0;
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
if (post != null) {
|
||||
delay = post.getInt("delay", 1000);
|
||||
}
|
||||
|
||||
// make a delay to see how the ssi loads and displays this page
|
||||
try {Thread.sleep(delay);} catch (InterruptedException e) {}
|
||||
|
||||
prop.put("delay", delay);
|
||||
prop.put("start", start);
|
||||
prop.put("stop", System.currentTimeMillis());
|
||||
|
||||
return prop;
|
||||
}
|
||||
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
// httpdAbstractHandler.java
|
||||
// -----------------------
|
||||
// (C) by Michael Peter Christen; mc@anomic.de
|
||||
// first published on http://www.anomic.de
|
||||
// Frankfurt, Germany, 2004
|
||||
// last major change: 25.10.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
|
||||
//
|
||||
// Using this software in any meaning (reading, learning, copying, compiling,
|
||||
// running) means that you agree that the Author(s) is (are) not responsible
|
||||
// for cost, loss of data or any harm that may be caused directly or indirectly
|
||||
// by usage of this softare or this documentation. The usage of this software
|
||||
// is on your own risk. The installation and usage (starting/running) of this
|
||||
// software may allow other people or application to access your computer and
|
||||
// any attached devices and is highly dependent on the configuration of the
|
||||
// software which must be done by the user of the software; the author(s) is
|
||||
// (are) also not responsible for proper configuration and usage of the
|
||||
// software, even if provoked by documentation provided together with
|
||||
// the software.
|
||||
//
|
||||
// Any changes to this file according to the GPL as documented in the file
|
||||
// gpl.txt aside this file in the shipment you received can be done to the
|
||||
// lines that follows this copyright notice here, but changes must not be
|
||||
// done inside the copyright notive above. A re-distribution must contain
|
||||
// the intact and unchanged copyright notice.
|
||||
// Contributions and changes to the program code must be marked as such.
|
||||
|
||||
/*
|
||||
Documentation:
|
||||
the servlet interface
|
||||
an actual servlet for the AnomicHTTPD must provide a class that implements
|
||||
this interface. The resulting class is then placed in a folder that contains
|
||||
all servlets and is configured in the httpd.conf configuration file.
|
||||
servlet classes in that directory are then automatically selected as CGI
|
||||
extensions to the server.
|
||||
The core functionality of file serving is also implemented as servlet.
|
||||
*/
|
||||
|
||||
package de.anomic.http;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Properties;
|
||||
|
||||
import de.anomic.server.logging.serverLog;
|
||||
|
||||
public abstract class httpdAbstractHandler {
|
||||
|
||||
// static tools
|
||||
|
||||
private static int fileCounter = 0; // for unique file names
|
||||
|
||||
private static SimpleDateFormat DateFileNameFormatter =
|
||||
new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
|
||||
protected static String uniqueDateString() {
|
||||
String c = Integer.toString(fileCounter);
|
||||
fileCounter++; if (fileCounter>9999) fileCounter = 0;
|
||||
while (c.length() < 4) { c = "0" + c; }
|
||||
return "FILE" + DateFileNameFormatter.format(httpc.nowDate()) + c;
|
||||
}
|
||||
|
||||
protected Properties connectionProperties = null;
|
||||
|
||||
protected serverLog theLogger;
|
||||
|
||||
}
|
@ -1,157 +0,0 @@
|
||||
// httpdHandler.java
|
||||
// -----------------------
|
||||
// (C) by Michael Peter Christen; mc@anomic.de
|
||||
// first published on http://www.anomic.de
|
||||
// Frankfurt, Germany, 2004
|
||||
// last major change: 03.01.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
|
||||
//
|
||||
// Using this software in any meaning (reading, learning, copying, compiling,
|
||||
// running) means that you agree that the Author(s) is (are) not responsible
|
||||
// for cost, loss of data or any harm that may be caused directly or indirectly
|
||||
// by usage of this softare or this documentation. The usage of this software
|
||||
// is on your own risk. The installation and usage (starting/running) of this
|
||||
// software may allow other people or application to access your computer and
|
||||
// any attached devices and is highly dependent on the configuration of the
|
||||
// software which must be done by the user of the software; the author(s) is
|
||||
// (are) also not responsible for proper configuration and usage of the
|
||||
// software, even if provoked by documentation provided together with
|
||||
// the software.
|
||||
//
|
||||
// Any changes to this file according to the GPL as documented in the file
|
||||
// gpl.txt aside this file in the shipment you received can be done to the
|
||||
// lines that follows this copyright notice here, but changes must not be
|
||||
// done inside the copyright notive above. A re-distribution must contain
|
||||
// the intact and unchanged copyright notice.
|
||||
// Contributions and changes to the program code must be marked as such.
|
||||
|
||||
/*
|
||||
Documentation:
|
||||
the servlet interface
|
||||
an actual servlet for the AnomicHTTPD must provide a class that implements
|
||||
this interface. The resulting class is then placed in a folder that contains
|
||||
all servlets and is configured in the httpd.conf configuration file.
|
||||
servlet classes in that directory are then automatically selected as CGI
|
||||
extensions to the server.
|
||||
The core functionality of file serving is also implemented as servlet.
|
||||
*/
|
||||
|
||||
package de.anomic.http;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PushbackInputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
public interface httpdHandler {
|
||||
|
||||
void doGet(Properties conProp, httpHeader header, OutputStream response) throws IOException;
|
||||
/*
|
||||
The GET method means retrieve whatever information (in the form of an
|
||||
entity) is identified by the Request-URI. If the Request-URI refers
|
||||
to a data-producing process, it is the produced data which shall be
|
||||
returned as the entity in the response and not the source text of the
|
||||
process, unless that text happens to be the output of the process.
|
||||
|
||||
The semantics of the GET method change to a "conditional GET" if the
|
||||
request message includes an If-Modified-Since, If-Unmodified-Since,
|
||||
If-Match, If-None-Match, or If-Range header field. A conditional GET
|
||||
method requests that the entity be transferred only under the
|
||||
circumstances described by the conditional header field(s). The
|
||||
conditional GET method is intended to reduce unnecessary network
|
||||
usage by allowing cached entities to be refreshed without requiring
|
||||
multiple requests or transferring data already held by the client.
|
||||
|
||||
The semantics of the GET method change to a "partial GET" if the
|
||||
request message includes a Range header field. A partial GET requests
|
||||
that only part of the entity be transferred, as described in section
|
||||
14.35. The partial GET method is intended to reduce unnecessary
|
||||
network usage by allowing partially-retrieved entities to be
|
||||
completed without transferring data already held by the client.
|
||||
*/
|
||||
|
||||
void doHead(Properties conProp, httpHeader header, OutputStream response) throws IOException;
|
||||
/*
|
||||
The HEAD method is identical to GET except that the server MUST NOT
|
||||
return a message-body in the response. The metainformation contained
|
||||
in the HTTP headers in response to a HEAD request SHOULD be identical
|
||||
to the information sent in response to a GET request. This method can
|
||||
be used for obtaining metainformation about the entity implied by the
|
||||
request without transferring the entity-body itself. This method is
|
||||
often used for testing hypertext links for validity, accessibility,
|
||||
and recent modification.
|
||||
|
||||
The response to a HEAD request MAY be cacheable in the sense that the
|
||||
information contained in the response MAY be used to update a
|
||||
previously cached entity from that resource. If the new field values
|
||||
indicate that the cached entity differs from the current entity (as
|
||||
would be indicated by a change in Content-Length, Content-MD5, ETag
|
||||
or Last-Modified), then the cache MUST treat the cache entry as
|
||||
stale.
|
||||
*/
|
||||
|
||||
void doPost(Properties conProp, httpHeader header, OutputStream response, PushbackInputStream body) throws IOException;
|
||||
/*
|
||||
The POST method is used to request that the origin server accept the
|
||||
entity enclosed in the request as a new subordinate of the resource
|
||||
identified by the Request-URI in the Request-Line. POST is designed
|
||||
to allow a uniform method to cover the following functions:
|
||||
|
||||
- Annotation of existing resources;
|
||||
|
||||
- Posting a message to a bulletin board, newsgroup, mailing list,
|
||||
or similar group of articles;
|
||||
|
||||
- Providing a block of data, such as the result of submitting a
|
||||
form, to a data-handling process;
|
||||
|
||||
- Extending a database through an append operation.
|
||||
|
||||
The actual function performed by the POST method is determined by the
|
||||
server and is usually dependent on the Request-URI. The posted entity
|
||||
is subordinate to that URI in the same way that a file is subordinate
|
||||
to a directory containing it, a news article is subordinate to a
|
||||
newsgroup to which it is posted, or a record is subordinate to a
|
||||
database.
|
||||
|
||||
The action performed by the POST method might not result in a
|
||||
resource that can be identified by a URI. In this case, either 200
|
||||
(OK) or 204 (No Content) is the appropriate response status,
|
||||
depending on whether or not the response includes an entity that
|
||||
describes the result.
|
||||
|
||||
If a resource has been created on the origin server, the response
|
||||
SHOULD be 201 (Created) and contain an entity which describes the
|
||||
status of the request and refers to the new resource, and a Location
|
||||
header (see section 14.30).
|
||||
|
||||
Responses to this method are not cacheable, unless the response
|
||||
includes appropriate Cache-Control or Expires header fields. However,
|
||||
the 303 (See Other) response can be used to direct the user agent to
|
||||
retrieve a cacheable resource.
|
||||
|
||||
POST requests MUST obey the message transmission requirements set out
|
||||
in section 8.2.
|
||||
*/
|
||||
|
||||
void doConnect(Properties conProp, httpHeader requestHeader, InputStream clientIn, OutputStream clientOut) throws IOException;
|
||||
/* this is only needed for https proxies. http daemons should throw a
|
||||
* UnsupportedOperationException
|
||||
*/
|
||||
|
||||
//public long getLastModified(Properties conProp);
|
||||
}
|
Loading…
Reference in new issue