forked from I2P_Developers/i2p.i2p
2005-09-21 susi
* Bugfix in susidns for deleting entries 2005-09-21 jrandom * Add support for HTTP POST to EepGet * Use HTTP POST for syndie bulk fetches, since there's a lot of data to put in that URL.
This commit is contained in:
@ -20,7 +20,7 @@
|
|||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
* $Revision: 1.22 $
|
* $Revision: 1.1 $
|
||||||
*/
|
*/
|
||||||
%>
|
%>
|
||||||
<%@ page contentType="text/html"%>
|
<%@ page contentType="text/html"%>
|
||||||
@ -136,7 +136,7 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<c:if test="${book.master}||${book.router}">
|
<c:if test="${book.master || book.router}">
|
||||||
<div id="buttons">
|
<div id="buttons">
|
||||||
<p class="buttons"><input type="image" name="action" value="delete" src="images/delete.png" alt="Delete checked" />
|
<p class="buttons"><input type="image" name="action" value="delete" src="images/delete.png" alt="Delete checked" />
|
||||||
</p>
|
</p>
|
||||||
|
@ -17,14 +17,14 @@ import net.i2p.syndie.data.*;
|
|||||||
*/
|
*/
|
||||||
public class ArchiveServlet extends HttpServlet {
|
public class ArchiveServlet extends HttpServlet {
|
||||||
|
|
||||||
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
String path = req.getPathInfo();
|
String path = req.getPathInfo();
|
||||||
if ( (path == null) || (path.trim().length() <= 1) ) {
|
if ( (path == null) || (path.trim().length() <= 1) ) {
|
||||||
renderRootIndex(resp);
|
renderRootIndex(resp);
|
||||||
return;
|
return;
|
||||||
} else if (path.endsWith(Archive.INDEX_FILE)) {
|
} else if (path.endsWith(Archive.INDEX_FILE)) {
|
||||||
renderSummary(resp);
|
renderSummary(resp);
|
||||||
} else if (path.endsWith("export.zip")) {
|
} else if (path.indexOf("export.zip") != -1) {
|
||||||
ExportServlet.export(req, resp);
|
ExportServlet.export(req, resp);
|
||||||
} else {
|
} else {
|
||||||
String blog = getBlog(path);
|
String blog = getBlog(path);
|
||||||
|
@ -24,17 +24,98 @@ import net.i2p.syndie.data.*;
|
|||||||
*/
|
*/
|
||||||
public class ExportServlet extends HttpServlet {
|
public class ExportServlet extends HttpServlet {
|
||||||
|
|
||||||
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
export(req, resp);
|
export(req, resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void export(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
public static void export(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
String meta[] = req.getParameterValues("meta");
|
try {
|
||||||
String entries[] = req.getParameterValues("entry");
|
doExport(req, resp);
|
||||||
|
} catch (ServletException se) {
|
||||||
|
se.printStackTrace();
|
||||||
|
throw se;
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
ioe.printStackTrace();
|
||||||
|
throw ioe;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static void doExport(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
|
String meta[] = null;
|
||||||
|
String entries[] = null;
|
||||||
|
String type = req.getHeader("Content-Type");
|
||||||
|
if ( (type == null) || (type.indexOf("boundary") == -1) ) {
|
||||||
|
// it has to be POSTed with the request, name=value pairs. the export servlet doesn't allow any
|
||||||
|
// free form fields, so no worry about newlines, so lets parse 'er up
|
||||||
|
List metaList = new ArrayList();
|
||||||
|
List entryList = new ArrayList();
|
||||||
|
StringBuffer key = new StringBuffer();
|
||||||
|
StringBuffer val = null;
|
||||||
|
String lenStr = req.getHeader("Content-length");
|
||||||
|
int len = -1;
|
||||||
|
if (lenStr != null)
|
||||||
|
try { len = Integer.valueOf(lenStr).intValue(); } catch (NumberFormatException nfe) {}
|
||||||
|
|
||||||
|
int read = 0;
|
||||||
|
int c = 0;
|
||||||
|
InputStream in = req.getInputStream();
|
||||||
|
while ( (len == -1) || (read < len) ){
|
||||||
|
c = in.read();
|
||||||
|
if ( (c == '=') && (val == null) ) {
|
||||||
|
val = new StringBuffer(128);
|
||||||
|
} else if ( (c == -1) || (c == '&') ) {
|
||||||
|
String k = (key == null ? "" : key.toString());
|
||||||
|
String v = (val == null ? "" : val.toString());
|
||||||
|
if ("meta".equals(k))
|
||||||
|
metaList.add(v.trim());
|
||||||
|
else if ("entry".equals(k))
|
||||||
|
entryList.add(v.trim());
|
||||||
|
key.setLength(0);
|
||||||
|
val = null;
|
||||||
|
// no newlines in the export servlet
|
||||||
|
if (c == -1)
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
if (val == null)
|
||||||
|
key.append((char)c);
|
||||||
|
else
|
||||||
|
val.append((char)c);
|
||||||
|
}
|
||||||
|
read++;
|
||||||
|
}
|
||||||
|
if (metaList != null) {
|
||||||
|
meta = new String[metaList.size()];
|
||||||
|
for (int i = 0; i < metaList.size(); i++)
|
||||||
|
meta[i] = (String)metaList.get(i);
|
||||||
|
}
|
||||||
|
if (entryList != null) {
|
||||||
|
entries = new String[entryList.size()];
|
||||||
|
for (int i = 0; i < entryList.size(); i++)
|
||||||
|
entries[i] = (String)entryList.get(i);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
meta = req.getParameterValues("meta");
|
||||||
|
entries = req.getParameterValues("entry");
|
||||||
|
}
|
||||||
resp.setContentType("application/x-syndie-zip");
|
resp.setContentType("application/x-syndie-zip");
|
||||||
resp.setStatus(200);
|
resp.setStatus(200);
|
||||||
OutputStream out = resp.getOutputStream();
|
OutputStream out = resp.getOutputStream();
|
||||||
ZipOutputStream zo = new ZipOutputStream(out);
|
|
||||||
|
if (false) {
|
||||||
|
StringBuffer bbuf = new StringBuffer(1024);
|
||||||
|
bbuf.append("meta: ");
|
||||||
|
if (meta != null)
|
||||||
|
for (int i = 0; i < meta.length; i++)
|
||||||
|
bbuf.append(meta[i]).append(", ");
|
||||||
|
bbuf.append("entries: ");
|
||||||
|
if (entries != null)
|
||||||
|
for (int i = 0; i < entries.length; i++)
|
||||||
|
bbuf.append(entries[i]).append(", ");
|
||||||
|
System.out.println(bbuf.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
ZipOutputStream zo = null;
|
||||||
|
if ( (meta != null) && (entries != null) && (meta.length + entries.length > 0) )
|
||||||
|
zo = new ZipOutputStream(out);
|
||||||
|
|
||||||
List metaFiles = getMetaFiles(meta);
|
List metaFiles = getMetaFiles(meta);
|
||||||
|
|
||||||
@ -62,8 +143,10 @@ public class ExportServlet extends HttpServlet {
|
|||||||
zo.closeEntry();
|
zo.closeEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
zo.finish();
|
if (zo != null) {
|
||||||
zo.close();
|
zo.finish();
|
||||||
|
zo.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List getMetaFiles(String blogHashes[]) {
|
private static List getMetaFiles(String blogHashes[]) {
|
||||||
|
@ -160,27 +160,28 @@ public class RemoteArchiveBean {
|
|||||||
if (_exportCapable) {
|
if (_exportCapable) {
|
||||||
StringBuffer url = new StringBuffer(512);
|
StringBuffer url = new StringBuffer(512);
|
||||||
url.append(buildExportURL());
|
url.append(buildExportURL());
|
||||||
|
StringBuffer postData = new StringBuffer(512);
|
||||||
Set meta = new HashSet();
|
Set meta = new HashSet();
|
||||||
for (int i = 0; i < entries.length; i++) {
|
for (int i = 0; i < entries.length; i++) {
|
||||||
BlogURI uri = new BlogURI(entries[i]);
|
BlogURI uri = new BlogURI(entries[i]);
|
||||||
if (uri.getEntryId() >= 0) {
|
if (uri.getEntryId() >= 0) {
|
||||||
url.append("entry=").append(uri.toString()).append('&');
|
postData.append("entry=").append(uri.toString()).append('&');
|
||||||
meta.add(uri.getKeyHash());
|
meta.add(uri.getKeyHash());
|
||||||
_statusMessages.add("Scheduling bulk blog post fetch of " + HTMLRenderer.sanitizeString(entries[i]));
|
_statusMessages.add("Scheduling bulk blog post fetch of " + HTMLRenderer.sanitizeString(entries[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Iterator iter = meta.iterator(); iter.hasNext(); ) {
|
for (Iterator iter = meta.iterator(); iter.hasNext(); ) {
|
||||||
Hash blog = (Hash)iter.next();
|
Hash blog = (Hash)iter.next();
|
||||||
url.append("meta=").append(blog.toBase64()).append('&');
|
postData.append("meta=").append(blog.toBase64()).append('&');
|
||||||
_statusMessages.add("Scheduling bulk blog metadata fetch of " + blog.toBase64());
|
_statusMessages.add("Scheduling bulk blog metadata fetch of " + blog.toBase64());
|
||||||
}
|
}
|
||||||
List urls = new ArrayList(1);
|
|
||||||
urls.add(url.toString());
|
|
||||||
List tmpFiles = new ArrayList(1);
|
|
||||||
try {
|
try {
|
||||||
File tmp = File.createTempFile("fetchBulk", ".zip", BlogManager.instance().getTempDir());
|
File tmp = File.createTempFile("fetchBulk", ".zip", BlogManager.instance().getTempDir());
|
||||||
tmpFiles.add(tmp);
|
|
||||||
fetch(urls, tmpFiles, user, new BulkFetchListener(tmp));
|
boolean shouldProxy = (_proxyHost != null) && (_proxyPort > 0);
|
||||||
|
EepGet get = new EepGet(_context, shouldProxy, _proxyHost, _proxyPort, 0, tmp.getAbsolutePath(), url.toString(), postData.toString());
|
||||||
|
get.addStatusListener(new BulkFetchListener(tmp));
|
||||||
|
get.fetch();
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
_statusMessages.add("Internal error creating temporary file to fetch " + HTMLRenderer.sanitizeString(url.toString()) + ": " + ioe.getMessage());
|
_statusMessages.add("Internal error creating temporary file to fetch " + HTMLRenderer.sanitizeString(url.toString()) + ": " + ioe.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<% request.setCharacterEncoding("UTF-8"); %>
|
<%@page autoFlush="false" %><%
|
||||||
<%
|
|
||||||
|
request.setCharacterEncoding("UTF-8");
|
||||||
java.util.Map params = request.getParameterMap();
|
java.util.Map params = request.getParameterMap();
|
||||||
response.setContentType(net.i2p.syndie.web.ArchiveViewerBean.getAttachmentContentType(params));
|
response.setContentType(net.i2p.syndie.web.ArchiveViewerBean.getAttachmentContentType(params));
|
||||||
int len = net.i2p.syndie.web.ArchiveViewerBean.getAttachmentContentLength(params);
|
int len = net.i2p.syndie.web.ArchiveViewerBean.getAttachmentContentLength(params);
|
||||||
|
@ -35,6 +35,7 @@ public class EepGet {
|
|||||||
private int _numRetries;
|
private int _numRetries;
|
||||||
private String _outputFile;
|
private String _outputFile;
|
||||||
private String _url;
|
private String _url;
|
||||||
|
private String _postData;
|
||||||
private boolean _allowCaching;
|
private boolean _allowCaching;
|
||||||
private List _listeners;
|
private List _listeners;
|
||||||
|
|
||||||
@ -65,7 +66,13 @@ public class EepGet {
|
|||||||
public EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort, int numRetries, String outputFile, String url) {
|
public EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort, int numRetries, String outputFile, String url) {
|
||||||
this(ctx, shouldProxy, proxyHost, proxyPort, numRetries, outputFile, url, true, null);
|
this(ctx, shouldProxy, proxyHost, proxyPort, numRetries, outputFile, url, true, null);
|
||||||
}
|
}
|
||||||
|
public EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort, int numRetries, String outputFile, String url, String postData) {
|
||||||
|
this(ctx, shouldProxy, proxyHost, proxyPort, numRetries, outputFile, url, true, null, postData);
|
||||||
|
}
|
||||||
public EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort, int numRetries, String outputFile, String url, boolean allowCaching, String etag) {
|
public EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort, int numRetries, String outputFile, String url, boolean allowCaching, String etag) {
|
||||||
|
this(ctx, shouldProxy, proxyHost, proxyPort, numRetries, outputFile, url, allowCaching, etag, null);
|
||||||
|
}
|
||||||
|
public EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort, int numRetries, String outputFile, String url, boolean allowCaching, String etag, String postData) {
|
||||||
_context = ctx;
|
_context = ctx;
|
||||||
_log = ctx.logManager().getLog(EepGet.class);
|
_log = ctx.logManager().getLog(EepGet.class);
|
||||||
_shouldProxy = shouldProxy;
|
_shouldProxy = shouldProxy;
|
||||||
@ -74,6 +81,7 @@ public class EepGet {
|
|||||||
_numRetries = numRetries;
|
_numRetries = numRetries;
|
||||||
_outputFile = outputFile;
|
_outputFile = outputFile;
|
||||||
_url = url;
|
_url = url;
|
||||||
|
_postData = postData;
|
||||||
_alreadyTransferred = 0;
|
_alreadyTransferred = 0;
|
||||||
_bytesTransferred = 0;
|
_bytesTransferred = 0;
|
||||||
_bytesRemaining = -1;
|
_bytesRemaining = -1;
|
||||||
@ -562,29 +570,40 @@ public class EepGet {
|
|||||||
|
|
||||||
private String getRequest() {
|
private String getRequest() {
|
||||||
StringBuffer buf = new StringBuffer(512);
|
StringBuffer buf = new StringBuffer(512);
|
||||||
buf.append("GET ").append(_url).append(" HTTP/1.1\n");
|
boolean post = false;
|
||||||
|
if ( (_postData != null) && (_postData.length() > 0) )
|
||||||
|
post = true;
|
||||||
|
if (post) {
|
||||||
|
buf.append("POST ").append(_url).append(" HTTP/1.1\r\n");
|
||||||
|
} else {
|
||||||
|
buf.append("GET ").append(_url).append(" HTTP/1.1\r\n");
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
URL url = new URL(_url);
|
URL url = new URL(_url);
|
||||||
buf.append("Host: ").append(url.getHost()).append("\n");
|
buf.append("Host: ").append(url.getHost()).append("\r\n");
|
||||||
} catch (MalformedURLException mue) {
|
} catch (MalformedURLException mue) {
|
||||||
mue.printStackTrace();
|
mue.printStackTrace();
|
||||||
}
|
}
|
||||||
if (_alreadyTransferred > 0) {
|
if (_alreadyTransferred > 0) {
|
||||||
buf.append("Range: bytes=");
|
buf.append("Range: bytes=");
|
||||||
buf.append(_alreadyTransferred);
|
buf.append(_alreadyTransferred);
|
||||||
buf.append("-\n");
|
buf.append("-\r\n");
|
||||||
}
|
}
|
||||||
buf.append("Accept-Encoding: identity;q=1, *;q=0\n");
|
buf.append("Accept-Encoding: identity;q=1, *;q=0\r\n");
|
||||||
if (!_allowCaching) {
|
if (!_allowCaching) {
|
||||||
buf.append("Cache-control: no-cache\n");
|
buf.append("Cache-control: no-cache\r\n");
|
||||||
buf.append("Pragma: no-cache\n");
|
buf.append("Pragma: no-cache\r\n");
|
||||||
}
|
}
|
||||||
if (_etag != null) {
|
if (_etag != null) {
|
||||||
buf.append("If-None-Match: ");
|
buf.append("If-None-Match: ");
|
||||||
buf.append(_etag);
|
buf.append(_etag);
|
||||||
buf.append("\n");
|
buf.append("\r\n");
|
||||||
}
|
}
|
||||||
buf.append("Connection: close\n\n");
|
if (post)
|
||||||
|
buf.append("Content-length: ").append(_postData.length()).append("\r\n");
|
||||||
|
buf.append("Connection: close\r\n\r\n");
|
||||||
|
if (post)
|
||||||
|
buf.append(_postData);
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("Request: [" + buf.toString() + "]");
|
_log.debug("Request: [" + buf.toString() + "]");
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
|
10
history.txt
10
history.txt
@ -1,4 +1,12 @@
|
|||||||
$Id: history.txt,v 1.260 2005/09/18 18:08:18 jrandom Exp $
|
$Id: history.txt,v 1.261 2005/09/18 19:56:47 ragnarok Exp $
|
||||||
|
|
||||||
|
2005-09-21 susi
|
||||||
|
* Bugfix in susidns for deleting entries
|
||||||
|
|
||||||
|
2005-09-21 jrandom
|
||||||
|
* Add support for HTTP POST to EepGet
|
||||||
|
* Use HTTP POST for syndie bulk fetches, since there's a lot of data to
|
||||||
|
put in that URL.
|
||||||
|
|
||||||
2005-09-18 jrandom
|
2005-09-18 jrandom
|
||||||
* Added support for pure 64bit linux with jbigi and the java service
|
* Added support for pure 64bit linux with jbigi and the java service
|
||||||
|
@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class RouterVersion {
|
public class RouterVersion {
|
||||||
public final static String ID = "$Revision: 1.241 $ $Date: 2005/09/17 20:29:59 $";
|
public final static String ID = "$Revision: 1.242 $ $Date: 2005/09/18 18:08:18 $";
|
||||||
public final static String VERSION = "0.6.0.6";
|
public final static String VERSION = "0.6.0.6";
|
||||||
public final static long BUILD = 1;
|
public final static long BUILD = 2;
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
|
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
|
||||||
System.out.println("Router ID: " + RouterVersion.ID);
|
System.out.println("Router ID: " + RouterVersion.ID);
|
||||||
|
Reference in New Issue
Block a user