Author: toad
Date: 2006-01-14 17:36:25 +0000 (Sat, 14 Jan 2006)
New Revision: 7856
Modified:
trunk/freenet/src/freenet/client/FetchException.java
trunk/freenet/src/freenet/client/Fetcher.java
trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
trunk/freenet/src/freenet/node/Version.java
Log:
352:
Fix SSK-related redirect issues. We can now have manifest redirects.
(The complication here is that meta strings can be passed across redirects).
Don't dump all received lines to stdout in fproxy.
Modified: trunk/freenet/src/freenet/client/FetchException.java
===================================================================
--- trunk/freenet/src/freenet/client/FetchException.java 2006-01-14
17:01:33 UTC (rev 7855)
+++ trunk/freenet/src/freenet/client/FetchException.java 2006-01-14
17:36:25 UTC (rev 7856)
@@ -116,6 +116,8 @@
return "Metadata too big";
case TOO_MANY_BLOCKS_PER_SEGMENT:
return "Too many blocks per segment";
+ case NOT_ENOUGH_METASTRINGS:
+ return "No default document; give more metastrings in
URI";
default:
return "Unknown fetch error code: "+mode;
}
@@ -169,4 +171,6 @@
public static final int TOO_BIG_METADATA = 22;
/** Splitfile has too big segments */
public static final int TOO_MANY_BLOCKS_PER_SEGMENT = 23;
+ /** Not enough meta strings in URI given and no default document */
+ public static final int NOT_ENOUGH_METASTRINGS = 24;
}
Modified: trunk/freenet/src/freenet/client/Fetcher.java
===================================================================
--- trunk/freenet/src/freenet/client/Fetcher.java 2006-01-14 17:01:33 UTC
(rev 7855)
+++ trunk/freenet/src/freenet/client/Fetcher.java 2006-01-14 17:36:25 UTC
(rev 7856)
@@ -2,6 +2,7 @@
import java.io.IOException;
import java.net.MalformedURLException;
+import java.util.Iterator;
import java.util.LinkedList;
import freenet.client.events.DecodedBlockEvent;
@@ -63,7 +64,20 @@
for(int i=0;i<ctx.maxArchiveRestarts;i++) {
try {
ClientMetadata dm = new ClientMetadata();
- return realRun(dm, 0, origURI,
ctx.dontEnterImplicitArchives, ctx.localRequestOnly);
+ ClientKey key;
+ try {
+ key = ClientKey.getBaseKey(origURI);
+ } catch (MalformedURLException e2) {
+ throw new
FetchException(FetchException.INVALID_URI, "Invalid URI: "+origURI);
+ }
+ LinkedList metaStrings =
origURI.listMetaStrings();
+
+ FetchResult fr = realRun(dm, 0, key,
metaStrings, ctx.dontEnterImplicitArchives, ctx.localRequestOnly);
+
+ if(metaStrings.isEmpty()) return fr;
+ // Still got some meta-strings
+ throw new
FetchException(FetchException.HAS_MORE_METASTRINGS);
+
} catch (ArchiveRestartException e) {
archiveContext = new ArchiveContext();
continue;
@@ -77,6 +91,19 @@
}
throw new
FetchException(FetchException.TOO_MANY_ARCHIVE_RESTARTS);
}
+
+ FetchResult realRun(ClientMetadata dm, int recursionLevel, FreenetURI
uri, boolean dontEnterImplicitArchives, boolean localOnly)
+ throws FetchException, MetadataParseException, ArchiveFailureException,
ArchiveRestartException {
+ ClientKey key;
+ try {
+ key = ClientKey.getBaseKey(origURI);
+ } catch (MalformedURLException e2) {
+ throw new FetchException(FetchException.INVALID_URI,
"Invalid URI: "+origURI);
+ }
+ LinkedList metaStrings = origURI.listMetaStrings();
+
+ return realRun(dm, recursionLevel, key, metaStrings,
dontEnterImplicitArchives, localOnly);
+ }
/**
* Fetch a key, within an overall fetch process. Called by self in
recursion, and
@@ -91,17 +118,9 @@
* @throws ArchiveFailureException If we could not extract data from an
archive.
* @throws ArchiveRestartException
*/
- FetchResult realRun(ClientMetadata dm, int recursionLevel, FreenetURI
uri, boolean dontEnterImplicitArchives, boolean localOnly)
+ FetchResult realRun(ClientMetadata dm, int recursionLevel, ClientKey
key, LinkedList metaStrings, boolean dontEnterImplicitArchives, boolean
localOnly)
throws FetchException, MetadataParseException, ArchiveFailureException,
ArchiveRestartException {
- Logger.minor(this, "Running fetch for: "+uri);
- ClientKey key;
- try {
- key = ClientKey.getBaseKey(uri);
- } catch (MalformedURLException e2) {
- throw new FetchException(FetchException.INVALID_URI,
"Invalid URI: "+uri);
- }
- LinkedList metaStrings = uri.listMetaStrings();
-
+ Logger.minor(this, "Running fetch for: "+key);
recursionLevel++;
if(recursionLevel > ctx.maxRecursionLevel)
throw new
FetchException(FetchException.TOO_MUCH_RECURSION, ""+recursionLevel+" should be
< "+ctx.maxRecursionLevel);
@@ -166,10 +185,7 @@
ctx.eventProducer.produceEvent(new FetchedMetadataEvent());
- FetchResult result = runMetadata(dm, recursionLevel, key,
metaStrings, metadata, null, key.getURI(), dontEnterImplicitArchives,
localOnly);
- if(metaStrings.isEmpty()) return result;
- // Still got some meta-strings
- throw new FetchException(FetchException.HAS_MORE_METASTRINGS);
+ return runMetadata(dm, recursionLevel, key, metaStrings,
metadata, null, key.getURI(), dontEnterImplicitArchives, localOnly);
}
/**
@@ -180,7 +196,6 @@
* @param metaStrings List of unused meta strings (to be used by
manifests).
* @param metadata The parsed metadata to process.
* @param container The container in which this metadata is found.
- * @return
* @throws MetadataParseException If we could not parse metadata from a
sub-document. Will be
* converted to a FetchException above.
* @throws ArchiveFailureException If extracting data from an archive
failed.
@@ -200,9 +215,13 @@
// Since metadata is a document, we just replace
metadata here
if(name == null) {
metadata = metadata.getDefaultDocument();
+ if(metadata == null)
+ throw new
FetchException(FetchException.NOT_ENOUGH_METASTRINGS);
} else {
metadata = metadata.getDocument(name);
thisKey = thisKey.pushMetaString(name);
+ if(metadata == null)
+ throw new
FetchException(FetchException.NOT_IN_ARCHIVE);
}
return runMetadata(dm, recursionLevel, key,
metaStrings, metadata, container, thisKey, dontEnterImplicitArchives,
localOnly);
} else if(metadata.isArchiveManifest()) {
@@ -275,7 +294,24 @@
return runMetadata(dm,
recursionLevel+1, key, metaStrings, metadata, container, thisKey,
dontEnterImplicitArchives, localOnly);
} // else just fetch it, create context later
}
- FetchResult fr = realRun(dm, recursionLevel, uri,
dontEnterImplicitArchives, localOnly);
+
+
+ ClientKey newKey;
+ try {
+ newKey = ClientKey.getBaseKey(uri);
+ } catch (MalformedURLException e2) {
+ throw new
FetchException(FetchException.INVALID_URI, "Invalid URI: "+uri);
+ }
+
+ LinkedList newMetaStrings = uri.listMetaStrings();
+
+ // Move any new meta strings to beginning of our list
of remaining meta strings
+ while(!newMetaStrings.isEmpty()) {
+ Object o = newMetaStrings.removeLast();
+ metaStrings.addFirst(o);
+ }
+
+ FetchResult fr = realRun(dm, recursionLevel, newKey,
metaStrings, dontEnterImplicitArchives, localOnly);
if(metadata.isCompressed()) {
Compressor codec =
Compressor.getCompressionAlgorithmByMetadataID(metadata.compressionCodec);
Bucket data = fr.data;
Modified: trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
2006-01-14 17:01:33 UTC (rev 7855)
+++ trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
2006-01-14 17:36:25 UTC (rev 7856)
@@ -143,7 +143,7 @@
while(true) {
String line = lis.readLine(32768, 128);
-
System.out.println("Length="+line.length()+": "+line);
+
//System.out.println("Length="+line.length()+": "+line);
if(line.length() == 0) break;
int index = line.indexOf(':');
String before = line.substring(0,
index);
Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-01-14 17:01:33 UTC (rev
7855)
+++ trunk/freenet/src/freenet/node/Version.java 2006-01-14 17:36:25 UTC (rev
7856)
@@ -20,7 +20,7 @@
public static final String protocolVersion = "1.0";
/** The build number of the current revision */
- public static final int buildNumber = 351;
+ public static final int buildNumber = 352;
/** Oldest build of Fred we will talk to */
public static final int lastGoodBuild = 348;