aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/pom.xml88
-rw-r--r--core/src/main/java/fi/iki/elonen/NanoHTTPD.java (renamed from src/main/java/fi/iki/elonen/NanoHTTPD.java)0
-rw-r--r--pom.xml20
-rw-r--r--samples/pom.xml96
-rw-r--r--samples/src/main/java/fi/iki/elonen/FileUploadTesting.java (renamed from src/main/java/fi/iki/elonen/FileUploadTesting.java)0
-rw-r--r--samples/src/main/java/fi/iki/elonen/HelloServer.java (renamed from src/main/java/fi/iki/elonen/HelloServer.java)0
-rw-r--r--samples/src/main/java/fi/iki/elonen/SimpleWebServer.java (renamed from src/main/java/fi/iki/elonen/SimpleWebServer.java)24
-rw-r--r--samples/src/test/resources/file-upload-test.htm (renamed from src/test/resources/file-upload-test.htm)0
8 files changed, 202 insertions, 26 deletions
diff --git a/core/pom.xml b/core/pom.xml
new file mode 100644
index 0000000..d626d51
--- /dev/null
+++ b/core/pom.xml
@@ -0,0 +1,88 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>fi.iki.elonen</groupId>
+ <artifactId>nanohttpd</artifactId>
+ <version>1.0.0</version>
+ <packaging>jar</packaging>
+
+ <name>NanoHTTPd</name>
+ <url>http://maven.apache.org</url>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <distributionManagement>
+ <repository>
+ <id>fictional-io</id>
+ <name>fictional.io</name>
+ <url>ftp://fictional.io/domains/fictional.io/public_html/maven/maven2</url>
+ <uniqueVersion>false</uniqueVersion>
+ </repository>
+ <snapshotRepository>
+ <id>fictional-io</id>
+ <name>fictional.io</name>
+ <url>ftp://fictional.io/domains/fictional.io/public_html/maven/maven2</url>
+ <uniqueVersion>false</uniqueVersion>
+ </snapshotRepository>
+ </distributionManagement>
+
+ <scm>
+ <connection>scm:git:git://github.com/psh/nanohttpd.git</connection>
+ <url>scm:git:git://github.com/psh/nanohttpd.git</url>
+ <developerConnection>scm:git:git://github.com/psh/nanohttpd.git</developerConnection>
+ <tag>nanohttpd-1.0.0</tag>
+ </scm>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.jvnet.wagon-svn</groupId>
+ <artifactId>wagon-svn</artifactId>
+ <version>1.8</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-ftp</artifactId>
+ <version>1.0-alpha-6</version>
+ </extension>
+ </extensions>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.2.1</version>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-release-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.9</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/src/main/java/fi/iki/elonen/NanoHTTPD.java b/core/src/main/java/fi/iki/elonen/NanoHTTPD.java
index 370186b..370186b 100644
--- a/src/main/java/fi/iki/elonen/NanoHTTPD.java
+++ b/core/src/main/java/fi/iki/elonen/NanoHTTPD.java
diff --git a/pom.xml b/pom.xml
index 9ed95eb..3d23678 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,27 +2,21 @@
<modelVersion>4.0.0</modelVersion>
<groupId>fi.iki.elonen</groupId>
- <artifactId>nanohttpd</artifactId>
+ <artifactId>nanohttpd-project</artifactId>
<version>1.0.0</version>
- <packaging>jar</packaging>
+ <packaging>pom</packaging>
- <name>NanoHTTPd</name>
+ <name>NanoHTTPd-Project</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <!-- <gson.version>2.2.2</gson.version> -->
</properties>
- <dependencies>
- <!--
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- <version>${gson.version}</version>
- </dependency>
- -->
- </dependencies>
+ <modules>
+ <module>core</module>
+ <module>samples</module>
+ </modules>
<distributionManagement>
<repository>
diff --git a/samples/pom.xml b/samples/pom.xml
new file mode 100644
index 0000000..cd955bd
--- /dev/null
+++ b/samples/pom.xml
@@ -0,0 +1,96 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>fi.iki.elonen</groupId>
+ <artifactId>nanohttpd-samples</artifactId>
+ <version>1.0.0</version>
+ <packaging>jar</packaging>
+
+ <name>NanoHTTPd-samples</name>
+ <url>http://maven.apache.org</url>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>fi.iki.elonen</groupId>
+ <artifactId>nanohttpd</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ </dependencies>
+
+ <distributionManagement>
+ <repository>
+ <id>fictional-io</id>
+ <name>fictional.io</name>
+ <url>ftp://fictional.io/domains/fictional.io/public_html/maven/maven2</url>
+ <uniqueVersion>false</uniqueVersion>
+ </repository>
+ <snapshotRepository>
+ <id>fictional-io</id>
+ <name>fictional.io</name>
+ <url>ftp://fictional.io/domains/fictional.io/public_html/maven/maven2</url>
+ <uniqueVersion>false</uniqueVersion>
+ </snapshotRepository>
+ </distributionManagement>
+
+ <scm>
+ <connection>scm:git:git://github.com/psh/nanohttpd.git</connection>
+ <url>scm:git:git://github.com/psh/nanohttpd.git</url>
+ <developerConnection>scm:git:git://github.com/psh/nanohttpd.git</developerConnection>
+ <tag>nanohttpd-1.0.0</tag>
+ </scm>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.jvnet.wagon-svn</groupId>
+ <artifactId>wagon-svn</artifactId>
+ <version>1.8</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-ftp</artifactId>
+ <version>1.0-alpha-6</version>
+ </extension>
+ </extensions>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.2.1</version>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-release-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.9</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/src/main/java/fi/iki/elonen/FileUploadTesting.java b/samples/src/main/java/fi/iki/elonen/FileUploadTesting.java
index f8326e1..f8326e1 100644
--- a/src/main/java/fi/iki/elonen/FileUploadTesting.java
+++ b/samples/src/main/java/fi/iki/elonen/FileUploadTesting.java
diff --git a/src/main/java/fi/iki/elonen/HelloServer.java b/samples/src/main/java/fi/iki/elonen/HelloServer.java
index 370b88b..370b88b 100644
--- a/src/main/java/fi/iki/elonen/HelloServer.java
+++ b/samples/src/main/java/fi/iki/elonen/HelloServer.java
diff --git a/src/main/java/fi/iki/elonen/SimpleWebServer.java b/samples/src/main/java/fi/iki/elonen/SimpleWebServer.java
index 6358692..8f94f80 100644
--- a/src/main/java/fi/iki/elonen/SimpleWebServer.java
+++ b/samples/src/main/java/fi/iki/elonen/SimpleWebServer.java
@@ -10,8 +10,6 @@ import java.util.Iterator;
import java.util.Map;
import java.util.StringTokenizer;
-import static fi.iki.elonen.NanoHTTPD.Response.Status.*;
-
public class SimpleWebServer extends NanoHTTPD {
/**
* Hashtable mapping (String)FILENAME_EXTENSION -> (String)MIME_TYPE
@@ -112,7 +110,7 @@ public class SimpleWebServer extends NanoHTTPD {
// Make sure we won't die of an exception later
if (!homeDir.isDirectory())
- res = new Response(INTERNAL_ERROR, MIME_PLAINTEXT, "INTERNAL ERRROR: serveFile(): given homeDir is not a directory.");
+ res = new Response(Response.Status.INTERNAL_ERROR, NanoHTTPD.MIME_PLAINTEXT, "INTERNAL ERRROR: serveFile(): given homeDir is not a directory.");
if (res == null) {
// Remove URL arguments
@@ -122,12 +120,12 @@ public class SimpleWebServer extends NanoHTTPD {
// Prohibit getting out of current directory
if (uri.startsWith("src/main") || uri.endsWith("src/main") || uri.contains("../"))
- res = new Response(FORBIDDEN, MIME_PLAINTEXT, "FORBIDDEN: Won't serve ../ for security reasons.");
+ res = new Response(Response.Status.FORBIDDEN, NanoHTTPD.MIME_PLAINTEXT, "FORBIDDEN: Won't serve ../ for security reasons.");
}
File f = new File(homeDir, uri);
if (res == null && !f.exists())
- res = new Response(NOT_FOUND, MIME_PLAINTEXT, "Error 404, file not found.");
+ res = new Response(Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT, "Error 404, file not found.");
// List the directory, if necessary
if (res == null && f.isDirectory()) {
@@ -135,7 +133,7 @@ public class SimpleWebServer extends NanoHTTPD {
// directory, send a redirect.
if (!uri.endsWith("/")) {
uri += "/";
- res = new Response(REDIRECT, MIME_HTML, "<html><body>Redirected: <a href=\"" + uri + "\">" + uri
+ res = new Response(Response.Status.REDIRECT, NanoHTTPD.MIME_HTML, "<html><body>Redirected: <a href=\"" + uri + "\">" + uri
+ "</a></body></html>");
res.addHeader("Location", uri);
}
@@ -190,7 +188,7 @@ public class SimpleWebServer extends NanoHTTPD {
msg += "</body></html>";
res = new Response(msg);
} else {
- res = new Response(FORBIDDEN, MIME_PLAINTEXT, "FORBIDDEN: No directory listing.");
+ res = new Response(Response.Status.FORBIDDEN, NanoHTTPD.MIME_PLAINTEXT, "FORBIDDEN: No directory listing.");
}
}
}
@@ -203,7 +201,7 @@ public class SimpleWebServer extends NanoHTTPD {
if (dot >= 0)
mime = MIME_TYPES.get(f.getCanonicalPath().substring(dot + 1).toLowerCase());
if (mime == null)
- mime = MIME_DEFAULT_BINARY;
+ mime = NanoHTTPD.MIME_DEFAULT_BINARY;
// Calculate etag
String etag = Integer.toHexString((f.getAbsolutePath() + f.lastModified() + "" + f.length()).hashCode());
@@ -230,7 +228,7 @@ public class SimpleWebServer extends NanoHTTPD {
long fileLen = f.length();
if (range != null && startFrom >= 0) {
if (startFrom >= fileLen) {
- res = new Response(RANGE_NOT_SATISFIABLE, MIME_PLAINTEXT, "");
+ res = new Response(Response.Status.RANGE_NOT_SATISFIABLE, NanoHTTPD.MIME_PLAINTEXT, "");
res.addHeader("Content-Range", "bytes 0-0/" + fileLen);
res.addHeader("ETag", etag);
} else {
@@ -249,23 +247,23 @@ public class SimpleWebServer extends NanoHTTPD {
};
fis.skip(startFrom);
- res = new Response(PARTIAL_CONTENT, mime, fis);
+ res = new Response(Response.Status.PARTIAL_CONTENT, mime, fis);
res.addHeader("Content-Length", "" + dataLen);
res.addHeader("Content-Range", "bytes " + startFrom + "-" + endAt + "/" + fileLen);
res.addHeader("ETag", etag);
}
} else {
if (etag.equals(header.get("if-none-match")))
- res = new Response(NOT_MODIFIED, mime, "");
+ res = new Response(Response.Status.NOT_MODIFIED, mime, "");
else {
- res = new Response(OK, mime, new FileInputStream(f));
+ res = new Response(Response.Status.OK, mime, new FileInputStream(f));
res.addHeader("Content-Length", "" + fileLen);
res.addHeader("ETag", etag);
}
}
}
} catch (IOException ioe) {
- res = new Response(FORBIDDEN, MIME_PLAINTEXT, "FORBIDDEN: Reading file failed.");
+ res = new Response(Response.Status.FORBIDDEN, NanoHTTPD.MIME_PLAINTEXT, "FORBIDDEN: Reading file failed.");
}
res.addHeader("Accept-Ranges", "bytes"); // Announce that the file server accepts partial content requestes
diff --git a/src/test/resources/file-upload-test.htm b/samples/src/test/resources/file-upload-test.htm
index 7d553bf..7d553bf 100644
--- a/src/test/resources/file-upload-test.htm
+++ b/samples/src/test/resources/file-upload-test.htm