fix NPE in QuickCrawlLink_p if param doesn't contain crawl url

pull/77/head
reger 9 years ago
parent e9b9a7f68f
commit bac302bfe4

@ -62,37 +62,37 @@ public class QuickCrawlLink_p {
final serverObjects prop = new serverObjects(); final serverObjects prop = new serverObjects();
final Switchboard sb = (Switchboard) env; final Switchboard sb = (Switchboard) env;
// get segment int port = sb.getConfigInt("port", 8090);
Segment indexSegment = sb.index;
if (post == null) {
// send back usage example
prop.put("mode", "0");
// get the http host header // get the http host header
if (header.containsKey(HeaderFramework.HOST)) {
final String hostSocket = header.get(HeaderFramework.HOST); final String hostSocket = header.get(HeaderFramework.HOST);
final int pos = hostSocket.indexOf(':', 0);
//String host = hostSocket;
int port = 80;
final int pos = hostSocket.indexOf(':',0);
if (pos != -1) { if (pos != -1) {
port = NumberTools.parseIntDecSubstring(hostSocket, pos + 1); port = NumberTools.parseIntDecSubstring(hostSocket, pos + 1);
//host = hostSocket.substring(0, pos);
} }
}
prop.put("mode_host", Domains.LOCALHOST); prop.put("mode_host", Domains.LOCALHOST);
prop.put("mode_port", port); prop.put("mode_port", port);
if (post == null) {
// send back usage example
prop.put("mode", "0");
return prop; return prop;
} }
prop.put("mode", "1");
// get the URL // get the URL
String crawlingStart = post.get("url",null); String crawlingStart = post.get("url",null);
if (crawlingStart != null) {
prop.put("mode", "1");
crawlingStart = UTF8.decodeURL(crawlingStart); crawlingStart = UTF8.decodeURL(crawlingStart);
// get segment
Segment indexSegment = sb.index;
// get the browser title // get the browser title
final String title = post.get("title",null); final String title = post.get("title", null);
// get other parameters if set // get other parameters if set
final String crawlingMustMatch = post.get("mustmatch", CrawlProfile.MATCH_ALL_STRING); final String crawlingMustMatch = post.get("mustmatch", CrawlProfile.MATCH_ALL_STRING);
@ -111,7 +111,6 @@ public class QuickCrawlLink_p {
prop.put("mode_url", (crawlingStart == null) ? "unknown" : crawlingStart); prop.put("mode_url", (crawlingStart == null) ? "unknown" : crawlingStart);
prop.putHTML("mode_title", (title == null) ? "unknown" : title); prop.putHTML("mode_title", (title == null) ? "unknown" : title);
if (crawlingStart != null) {
crawlingStart = crawlingStart.trim(); crawlingStart = crawlingStart.trim();
try {crawlingStart = new DigestURL(crawlingStart).toNormalform(true);} catch (final MalformedURLException e1) {} try {crawlingStart = new DigestURL(crawlingStart).toNormalform(true);} catch (final MalformedURLException e1) {}

Loading…
Cancel
Save