thrift-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ro...@apache.org
Subject svn commit: r1228717 - in /thrift/trunk/lib/js/test: build.xml src/test/Httpd.java
Date Sat, 07 Jan 2012 20:32:24 GMT
Author: roger
Date: Sat Jan  7 20:32:24 2012
New Revision: 1228717

URL: http://svn.apache.org/viewvc?rev=1228717&view=rev
Log:
THRIFT-1486 Javascript manual testserver not returning content types
Patch: Andrew Grumet

Modified:
    thrift/trunk/lib/js/test/build.xml
    thrift/trunk/lib/js/test/src/test/Httpd.java

Modified: thrift/trunk/lib/js/test/build.xml
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/js/test/build.xml?rev=1228717&r1=1228716&r2=1228717&view=diff
==============================================================================
--- thrift/trunk/lib/js/test/build.xml (original)
+++ thrift/trunk/lib/js/test/build.xml Sat Jan  7 20:32:24 2012
@@ -253,6 +253,7 @@
     <artifact:dependencies filesetId="js.test.dependency.jars">
       <dependency groupId="org.apache.httpcomponents" artifactId="httpclient" version="4.0.1"/>
       <dependency groupId="com.googlecode.jslint4java" artifactId="jslint4java-ant" version="1.4.6"/>
+      <dependency groupId="eu.medsea.mimeutil" artifactId="mime-util" version="2.1.3"/>
       <!-- get jstestdriver.jar via maven-->
       <remoteRepository id="jstd-maven-plugin google code repo" url="http://jstd-maven-plugin.googlecode.com/svn/maven2"/>
       <dependency groupId="com.google.jstestdriver" artifactId="maven-jstestdriver-plugin"
version="1.3.2.3"/>

Modified: thrift/trunk/lib/js/test/src/test/Httpd.java
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/js/test/src/test/Httpd.java?rev=1228717&r1=1228716&r2=1228717&view=diff
==============================================================================
--- thrift/trunk/lib/js/test/src/test/Httpd.java (original)
+++ thrift/trunk/lib/js/test/src/test/Httpd.java Sat Jan  7 20:32:24 2012
@@ -72,6 +72,12 @@ import org.apache.thrift.transport.TMemo
 import thrift.test.ThriftTest;
 import org.apache.thrift.server.ServerTestBase.TestHandler;
 
+import eu.medsea.mimeutil.detector.ExtensionMimeDetector;
+import eu.medsea.mimeutil.MimeUtil2;
+import eu.medsea.mimeutil.MimeType;
+import java.util.Collection;
+import java.util.Iterator;
+
 /**
  * Basic, yet fully functional and spec compliant, HTTP/1.1 file server.
  * <p>
@@ -177,8 +183,20 @@ public class Httpd {
 
                 } else {
 
+		    String mimeType = "application/octet-stream";
+		    MimeUtil2 mimeUtil = new MimeUtil2();
+		    mimeUtil.registerMimeDetector(ExtensionMimeDetector.class.getName());
+		    Collection<MimeType> collection = mimeUtil.getMimeTypes(file);
+		    Iterator<MimeType> iterator = collection.iterator();
+		    while(iterator.hasNext()) {
+			MimeType mt = iterator.next();
+			mimeType =  mt.getMediaType() + "/" + mt.getSubType();
+			break;
+		    }
+
                     response.setStatusCode(HttpStatus.SC_OK);
-                    FileEntity body = new FileEntity(file, "text/html");
+                    FileEntity body = new FileEntity(file, mimeType);
+                    response.addHeader("Content-Type", mimeType);
                     response.setEntity(body);
                     System.out.println("Serving file " + file.getPath());
 



Mime
View raw message