Permalink
Browse files

Fix call parameter for ConnectionInfo in MonitorHandler

(expected scheme e.g. http, was protocol version).
Depreceate obsolete custom X-...-Scheme header constant.
Use existing FORMAT_ANSIC Dateformatter in HeaderFramework.
Correct htmlParserTest (del one not intended println)
  • Loading branch information...
reger24 committed Feb 25, 2017
1 parent 9e626f6 commit 41e2ee0ecaafe6f32426e78cace5d990daa4456d
@@ -35,6 +35,7 @@
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import net.yacy.cora.date.GenericFormatter;
import net.yacy.cora.document.encoding.ASCII;
import net.yacy.cora.document.encoding.UTF8;
import net.yacy.cora.util.CommonPattern;
@@ -100,7 +101,8 @@
public static final String X_YACY_INDEX_CONTROL = "X-YaCy-Index-Control";
/** Added when generating legacy request header to allow template servlets to know the original request scheme : "http" or "https" */
public static final String X_YACY_REQUEST_SCHEME = "X-YaCy-Request-Scheme"; // TODO: after completing implementation of HttpServletRequest getScheme() should be used and this can be removed
@Deprecated /** use getScheme() (header not used in any request, 2017-02-22) */
public static final String X_YACY_REQUEST_SCHEME = "X-YaCy-Request-Scheme";
public static final String SET_COOKIE = "Set-Cookie";
public static final String SET_COOKIE2 = "Set-Cookie2";
@@ -223,10 +225,8 @@ public HeaderFramework(final Map<String, String> othermap) {
/** Date formatter/parser for standard compliant HTTP header dates (RFC 1123) */
private static final String PATTERN_RFC1123 = "EEE, dd MMM yyyy HH:mm:ss Z"; // with numeric time zone indicator as defined in RFC5322
private static final String PATTERN_RFC1036 = "EEEE, dd-MMM-yy HH:mm:ss zzz";
private static final String PATTERN_ANSIC = "EEE MMM d HH:mm:ss yyyy";
public static final SimpleDateFormat FORMAT_RFC1123 = new SimpleDateFormat(PATTERN_RFC1123, Locale.US);
public static final SimpleDateFormat FORMAT_RFC1036 = new SimpleDateFormat(PATTERN_RFC1036, Locale.US);
public static final SimpleDateFormat FORMAT_ANSIC = new SimpleDateFormat(PATTERN_ANSIC, Locale.US);
public static final SimpleDateFormat FORMAT_RFC1123 = new SimpleDateFormat(PATTERN_RFC1123, Locale.US);
public static final SimpleDateFormat FORMAT_RFC1036 = new SimpleDateFormat(PATTERN_RFC1036, Locale.US);
private static final TimeZone TZ_GMT = TimeZone.getTimeZone("GMT");
private static final Calendar CAL_GMT = Calendar.getInstance(TZ_GMT, Locale.US);
@@ -240,7 +240,7 @@ public HeaderFramework(final Map<String, String> othermap) {
// RFC 1036/850 (old) "Monday, 12-Nov-07 10:11:12 GMT"
FORMAT_RFC1036,
// ANSI C asctime() "Mon Nov 12 10:11:12 2007"
FORMAT_ANSIC,
GenericFormatter.FORMAT_ANSIC,
};
@@ -643,11 +643,7 @@ public String getScheme() {
if (_request != null) {
return _request.getScheme();
} else {
if (super.containsKey(HeaderFramework.X_YACY_REQUEST_SCHEME)) {
return super.get(HeaderFramework.X_YACY_REQUEST_SCHEME);
} else {
return "http";
}
return "http";
}
}
@@ -57,7 +57,7 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques
final Connection connection = baseRequest.getHttpChannel().getEndPoint().getConnection();
final ConnectionInfo info = new ConnectionInfo(
baseRequest.getProtocol(),
baseRequest.getScheme(),
baseRequest.getRemoteAddr() + ":" + baseRequest.getRemotePort(),
baseRequest.getMethod() + " " + baseRequest.getUri().getPathAndParam(),
connection.hashCode(),
@@ -705,7 +705,7 @@ public static String getContext(final RequestHeader header, final Switchboard sb
if("http".equals(protocolHeader) || "https".equals(protocolHeader)) {
protocol = protocolHeader.toLowerCase();
} else if(protocolHeader != null && !protocolHeader.isEmpty()) {
ConcurrentLog.warn("FILEHANDLER","YaCyDefaultServlet: illegal " + HeaderFramework.X_YACY_REQUEST_SCHEME + " header value : " + protocolHeader);
ConcurrentLog.warn("FILEHANDLER","YaCyDefaultServlet: illegal protocol scheme header value : " + protocolHeader);
}
/* This peer can also be behind a reverse proxy requested using https, even if the request coming to this YaCy peer is http only
@@ -167,9 +167,8 @@ public void testParteToScraper_ScriptTag() throws MalformedURLException, IOExcep
+ "</html>";
ContentScraper scraper = parseToScraper(url, charset, new VocabularyScraper(), 0, testhtml, 10);
System.out.println(scraper.getText());
String txt = scraper.getText();
System.out.println("ScraperTagTest: [" + textSource + "] = [" + txt + "]");
System.out.println("ScraperScriptTagTest: [" + textSource + "] = [" + txt + "]");
assertEquals(txt, textSource);
}
}

0 comments on commit 41e2ee0

Please sign in to comment.