Files
yacy_search_server/source/net/yacy/htroot/goto_p.java
Michael Peter Christen 8451cfdef8 enabling very large file uploads >2gb
This is a complete re-design of the serverObjects data structure which
holds all data that is submitted during http post requests to YaCy.
Before the change, post attributes had been stored to Strings which
cannot be larger than 2GB. Furthermore, byte[] uploads had been encoded
to b64 Strings to fit into this data structure. Those strings are now
replaced by a new data structure, ChunkedBytes which is an object that
can hold more than 2GB data using a list of byte[] objects. All required
streaming functions are implemented and streaming from http post upload
into this data structure works. The b64 encoding has been removed. The
ZIM and WARC reader make use of the new data structure.
2025-08-26 10:44:06 -07:00

87 lines
2.8 KiB
Java

// goto_p.java
// -----------------------
// part of YaCy
// (C) by Michael Peter Christen; mc@yacy.net
// first published on http://yacy.net
//
// $LastChangedDate$
// $LastChangedRevision$
// $LastChangedBy$
//
// 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
// You must compile this file with
// javac -classpath .:../Classes goto_p.java
// if the shell's current path is HTROOT
package net.yacy.htroot;
import java.util.Set;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.peers.Seed;
import net.yacy.search.Switchboard;
import net.yacy.server.serverObjects;
import net.yacy.server.serverSwitch;
/**
* forwards caller/browser to remote peer
*/
public class goto_p {
/**
* url parameter
*
* hash= of remote peer
* path= path part to forward to
*/
public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, final serverSwitch env) {
final Switchboard sb = (Switchboard) env;
final serverObjects prop = new serverObjects();
String hash = null;
if (post != null) {
hash = post.get("hash", ""); // get peers hash
}
if (hash != null && hash.length() > 0) {
final Seed seed = sb.peers.getConnected(hash);
if (seed != null) {
final Set<String> ips = seed.getIPs();
String peersUrl = null;
if(!ips.isEmpty()) {
peersUrl = seed.getPublicURL(ips.iterator().next(), false);
}
if (peersUrl != null) {
String path = post.get("path", "/");
if (!path.startsWith("/")) {
path = "/" + path;
}
prop.put(serverObjects.ACTION_LOCATION, peersUrl + path); // redirect command
} else {
prop.put("msg", "peer not available");
}
} else {
prop.put("msg", "peer not available");
}
} else {
prop.put("msg", "parameter missing");
}
return prop;
}
}