diff --git a/CHANGES.txt b/CHANGES.txt
index 5889578efe3..e9e918c814d 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -175,6 +175,10 @@ New Features
This will register: Luke/SystemInfo/PluginInfo/ThreadDump/PropertiesRequestHandler.
(ryan)
+
+35. SOLR-142: Added RawResponseWriter and ShowFileRequestHandler. This returns config
+ files directly. If the AdminHandlers is configured, this will be added automatically.
+ (ryan)
Changes in runtime behavior
diff --git a/example/solr/conf/solrconfig.xml b/example/solr/conf/solrconfig.xml
index d4b550ad8c2..4019718c5d6 100755
--- a/example/solr/conf/solrconfig.xml
+++ b/example/solr/conf/solrconfig.xml
@@ -502,7 +502,15 @@
+
+ If you wish to hide files under ${solr.home}/conf, explicitly register the ShowFileRequestHandler using:
+
+
+ synonyms.txt
+ anotherfile.txt
+
+
-->
diff --git a/src/java/org/apache/solr/core/SolrCore.java b/src/java/org/apache/solr/core/SolrCore.java
index 251508a1528..b46bf8b242d 100644
--- a/src/java/org/apache/solr/core/SolrCore.java
+++ b/src/java/org/apache/solr/core/SolrCore.java
@@ -54,6 +54,7 @@ import org.apache.solr.highlight.SolrHighlighter;
import org.apache.solr.request.JSONResponseWriter;
import org.apache.solr.request.PythonResponseWriter;
import org.apache.solr.request.QueryResponseWriter;
+import org.apache.solr.request.RawResponseWriter;
import org.apache.solr.request.RubyResponseWriter;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrQueryResponse;
@@ -968,7 +969,9 @@ public final class SolrCore {
if (responseWriters.get("ruby")==null) {
responseWriters.put("ruby", new RubyResponseWriter());
}
-
+ if (responseWriters.get("raw")==null) {
+ responseWriters.put("raw", new RawResponseWriter());
+ }
}
/** Finds a writer by name, or returns the default writer if not found. */
diff --git a/src/java/org/apache/solr/handler/admin/AdminHandlers.java b/src/java/org/apache/solr/handler/admin/AdminHandlers.java
index 90564bf9ace..a017772c1e3 100644
--- a/src/java/org/apache/solr/handler/admin/AdminHandlers.java
+++ b/src/java/org/apache/solr/handler/admin/AdminHandlers.java
@@ -84,7 +84,8 @@ public class AdminHandlers implements SolrCoreAware, SolrRequestHandler
new StandardHandler( "system", new SystemInfoHandler() ),
new StandardHandler( "plugins", new PluginInfoHandler() ),
new StandardHandler( "threads", new ThreadDumpHandler() ),
- new StandardHandler( "properties", new PropertiesRequestHandler() )
+ new StandardHandler( "properties", new PropertiesRequestHandler() ),
+ new StandardHandler( "file", new ShowFileRequestHandler() )
};
for( StandardHandler handler : list ) {
diff --git a/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java b/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java
new file mode 100644
index 00000000000..0fd5d83f0f2
--- /dev/null
+++ b/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java
@@ -0,0 +1,255 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.handler.admin;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrException.ErrorCode;
+import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.util.ContentStream;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.SimpleOrderedMap;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.core.SolrResourceLoader;
+import org.apache.solr.handler.RequestHandlerBase;
+import org.apache.solr.handler.RequestHandlerUtils;
+import org.apache.solr.request.RawResponseWriter;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.request.SolrQueryResponse;
+
+/**
+ * This handler uses the RawResponseWriter to give client access to
+ * files inside ${solr.home}/conf
+ *
+ * If you want to selectively restrict access some configuration files, you can list
+ * these files in the {@link #HIDDEN} invariants. For example to hide
+ * synonyms.txt and anotherfile.txt, you would register:
+ *
+ *
+ *
+ * The ShowFileRequestHandler uses the {@link RawResponseWriter} (wt=raw) to return
+ * file contents. If you need to use a different writer, you will need to change
+ * the registered invarient param for wt.
+ *
+ * If you want to override the contentType header returned for a given file, you can
+ * set it directly using: {@link #USE_CONTENT_TYPE}. For example, to get a plain text
+ * version of schema.xml, try:
+ *