public class NanoHTTPD extends Object implements IServiceShutdown
NanoHTTPD version 1.1, Copyright © 2001,2005-2007 Jarno Elonen (elonen@iki.fi, http://iki.fi/elonen/)
Various modifications since supporting integration within bigdata services © 2008, SYSTAP, LLC.
Features + limitations:
Ways to use:
Copyright (C) 2001,2005 by Jarno ElonenRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Modifier and Type | Class and Description |
---|---|
static class |
NanoHTTPD.Request
Deprecated.
A http request.
|
static class |
NanoHTTPD.Response
Deprecated.
HTTP response.
|
IServiceShutdown.Options
Modifier and Type | Field and Description |
---|---|
static String |
CONTENT_LENGTH
Deprecated.
|
static String |
CONTENT_TYPE
Deprecated.
|
static String |
DATE
Deprecated.
|
static String |
DELETE
Deprecated.
|
protected static String |
ERR_BAD_REQUEST
Deprecated.
|
static String |
GET
Deprecated.
|
static String |
HTTP_BADREQUEST
Deprecated.
Some HTTP response status codes
|
static String |
HTTP_FORBIDDEN
Deprecated.
Some HTTP response status codes
|
static String |
HTTP_INTERNALERROR
Deprecated.
Some HTTP response status codes
|
static String |
HTTP_METHOD_NOT_ALLOWED
Deprecated.
Some HTTP response status codes
|
static String |
HTTP_NOTFOUND
Deprecated.
Some HTTP response status codes
|
static String |
HTTP_NOTIMPLEMENTED
Deprecated.
Some HTTP response status codes
|
static String |
HTTP_OK
Deprecated.
Some HTTP response status codes
|
static String |
HTTP_REDIRECT
Deprecated.
Some HTTP response status codes
|
static String |
httpDefaultCharacterEncoding
Deprecated.
The name of the default character set encoding for HTTP which is
ISO-8859-1 . |
static String |
MIME_APPLICATION_URL_ENCODED
Deprecated.
Common mime types for dynamic content
|
static String |
MIME_APPLICATION_XML
Deprecated.
Common mime types for dynamic content
|
static String |
MIME_DEFAULT_BINARY
Deprecated.
Common mime types for dynamic content
|
static String |
MIME_TEXT_HTML
Deprecated.
Common mime types for dynamic content
|
static String |
MIME_TEXT_JAVASCRIPT
Deprecated.
Common mime types for dynamic content
|
static String |
MIME_TEXT_PLAIN
Deprecated.
Common mime types for dynamic content
|
static String |
POST
Deprecated.
|
static String |
PUT
Deprecated.
|
static String |
UTF8
Deprecated.
UTF-8 |
Constructor and Description |
---|
NanoHTTPD(int port)
Deprecated.
Starts a HTTP server to given port.
|
Modifier and Type | Method and Description |
---|---|
static LinkedHashMap<String,Vector<String>> |
decodeParams(String parms,
LinkedHashMap<String,Vector<String>> p)
Deprecated.
Decodes parameters in percent-encoded URI-format ( e.g.
|
static StringBuilder |
encodeParams(LinkedHashMap<String,Vector<String>> expected)
Deprecated.
Construct a percent encoded representation of the URL query parameters.
|
int |
getPort()
Deprecated.
The port on which the service was started.
|
boolean |
isOpen()
Deprecated.
Return
true iff the service is running. |
static void |
main(String[] args)
Deprecated.
Starts as a standalone file server and waits for Enter.
|
protected NanoHTTPD.Response |
serve(NanoHTTPD.Request req)
Deprecated.
Override this to customize the server.
|
protected NanoHTTPD.Response |
serveFile(String uri,
Map<String,String> header,
File homeDir,
boolean allowDirectoryListing)
Deprecated.
Serves file from homeDir and its' subdirectories (only).
|
void |
shutdown()
Deprecated.
The service will no longer accept new requests, but existing requests
will be processed (sychronous).
|
void |
shutdownNow()
Deprecated.
The service will no longer accept new requests and will make a best
effort attempt to terminate all existing requests and return ASAP.
|
public static final String UTF8
UTF-8
public static final String GET
public static final String PUT
public static final String POST
public static final String DELETE
protected static final String ERR_BAD_REQUEST
public static final String CONTENT_LENGTH
public static final String CONTENT_TYPE
public static final String DATE
public static final String httpDefaultCharacterEncoding
ISO-8859-1
. The character set of an HTTP entity is indicated
by the charset
parameter on the HTTP
Content-Type
header. This default MUST be applied when the
charset
parameter is not specified.public static final String HTTP_OK
public static final String HTTP_REDIRECT
public static final String HTTP_FORBIDDEN
public static final String HTTP_NOTFOUND
public static final String HTTP_BADREQUEST
public static final String HTTP_METHOD_NOT_ALLOWED
public static final String HTTP_INTERNALERROR
public static final String HTTP_NOTIMPLEMENTED
public static final String MIME_TEXT_PLAIN
public static final String MIME_TEXT_HTML
public static final String MIME_DEFAULT_BINARY
public static final String MIME_APPLICATION_XML
public static final String MIME_TEXT_JAVASCRIPT
public static final String MIME_APPLICATION_URL_ENCODED
public NanoHTTPD(int port) throws IOException
Throws an IOException if the socket is already in use
port
- The port. If 0
the the server will start on a
random port. The actual port is available from #getPort().IOException
protected NanoHTTPD.Response serve(NanoHTTPD.Request req)
public boolean isOpen()
IServiceShutdown
true
iff the service is running.isOpen
in interface IServiceShutdown
public void shutdown()
IServiceShutdown
IServiceShutdown.Options.SHUTDOWN_TIMEOUT
. Implementations SHOULD be
synchronized. If the service is aleady shutdown, then
this method should be a NOP.shutdown
in interface IServiceShutdown
public void shutdownNow()
IServiceShutdown
shutdownNow
in interface IServiceShutdown
public static void main(String[] args)
public int getPort()
protected NanoHTTPD.Response serveFile(String uri, Map<String,String> header, File homeDir, boolean allowDirectoryListing)
public static LinkedHashMap<String,Vector<String>> decodeParams(String parms, LinkedHashMap<String,Vector<String>> p) throws UnsupportedEncodingException
Map
.parms
- The URL query parameters.p
- A map of the parsed, percent decoded parameters (required).
The keys are the parameter names. Each value is a
Vector
of String
s containing the bindings for
the named parameter. The order of the URL parameters is
preserved by the insertion order of the LinkedHashMap
and the elements of the Vector
values.UnsupportedEncodingException
public static StringBuilder encodeParams(LinkedHashMap<String,Vector<String>> expected) throws UnsupportedEncodingException
expected
- The parameters.UnsupportedEncodingException
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.