return query;
}
protected void remoteCdxServerQuery(String urlkey, CDXQuery query, AuthToken authToken, CDXToSearchResultWriter resultWriter) throws IOException, AccessControlException
{
HTTPSeekableLineReader reader = null;
// This will throw AccessControlException if blocked
// (in fact, it throws RuntimeIOException wrapping AccessControlException)
cdxServer.getAuthChecker().createAccessFilter(authToken).includeUrl(urlkey, query.getUrl());
CloseableIterator<String> iter = null;
try {
StringBuilder sb = new StringBuilder(remoteCdxPath);
sb.append("?url=");
sb.append(URLEncoder.encode(query.getUrl(), "UTF-8"));
//sb.append(query.getUrl());
// sb.append("&limit=");
// sb.append(query.getLimit());
sb.append("&filter=");
sb.append(URLEncoder.encode(query.getFilter()[0], "UTF-8"));
// if (!query.getClosest().isEmpty()) {
// sb.append("&closest=");
// sb.append(query.getClosest().substring(0, 4));
// }
if (query.getCollapseTime() > 0) {
sb.append("&collapseTime=");
sb.append(query.getCollapseTime());
}
sb.append("&gzip=true");
String finalUrl = sb.toString();
reader = this.remoteCdxHttp.get(finalUrl);
if (remoteAuthCookie != null) {
String cookie;
if (authToken.isIgnoreRobots() && (remoteAuthCookieIgnoreRobots != null)) {
cookie = remoteAuthCookieIgnoreRobots;
} else {
cookie = remoteAuthCookie;
}
reader.setCookie(CDXServer.CDX_AUTH_TOKEN + "=" + cookie);
}
reader.setSaveErrHeader(HttpCDXWriter.RUNTIME_ERROR_HEADER);
reader.seekWithMaxRead(0, true, -1);
iter = createRemoteIter(urlkey, reader);
resultWriter.begin();
while (iter.hasNext() && !resultWriter.isAborted()) {
String rawLine = iter.next();
CDXLine line = cdxLineFactory.createStandardCDXLine(rawLine, StandardCDXLineFactory.cdx11);
resultWriter.writeLine(line);
}
resultWriter.end();
iter.close();
} finally {
if (reader != null) {
reader.close();
}
}
}