public class CorsHttpServer extends HttpServer
HttpServer.Handler, HttpServer.Request, HttpServer.Response| Modifier and Type | Field and Description | 
|---|---|
| static String | EXTRAHOSTS_PROPSystem property ("jsamp.web.extrahosts") which can be used to supply host addresses
 explicitly permitted to connect via the Web Profile alongside
 the local host. | 
HDR_CONTENT_TYPE, STATUS_OK| Constructor and Description | 
|---|
| CorsHttpServer(ServerSocket socket,
              OriginAuthorizer authorizer)Constructor. | 
| Modifier and Type | Method and Description | 
|---|---|
| static HttpServer.Response | createNonLocalErrorResponse(HttpServer.Request request)Returns an HTTP error response complaining about attempted access
 from a disallowed host. | 
| static boolean | isExtraHost(SocketAddress addr)Indicates whether a given address represents one of the "extra" hosts
 permitted to access this server alongside the localhost. | 
| static boolean | isLocalHost(SocketAddress address)Indicates whether the given socket address is from the local host. | 
| boolean | isPermittedHost(SocketAddress address)Indicates whether a network address is known to represent
 a host permitted to access this server. | 
| HttpServer.Response | serve(HttpServer.Request request)Does the work for providing output corresponding to a given HTTP request. | 
addHandler, create405Response, createErrorResponse, createErrorResponse, getBaseUrl, getHeader, getSocket, isRunning, removeHandler, serveRequest, setDaemon, start, stoppublic static final String EXTRAHOSTS_PROP
public CorsHttpServer(ServerSocket socket, OriginAuthorizer authorizer) throws IOException
socket - socket hosting the serviceauthorizer - defines which domains requests will be
                      permitted fromIOExceptionpublic HttpServer.Response serve(HttpServer.Request request)
HttpServerserve in class HttpServerrequest - represents an HTTP request that has been receivedpublic static HttpServer.Response createNonLocalErrorResponse(HttpServer.Request request)
request - offending requestpublic boolean isPermittedHost(SocketAddress address)
address - socket addresspublic static boolean isLocalHost(SocketAddress address)
address - socket to testpublic static boolean isExtraHost(SocketAddress addr)
addr - address of non-local host to testCopyright © 2008–2024. All rights reserved.