public class HTTPServer extends Object
Modifier and Type | Field and Description |
---|---|
protected static Set<String> |
DEFAULT_ALLOWED_IPS |
protected String |
host |
protected org.languagetool.server.LanguageToolHttpHandler |
httpHandler |
protected int |
port |
protected com.sun.net.httpserver.HttpServer |
server |
Constructor and Description |
---|
HTTPServer()
Prepare a server on the given port - use run() to start it.
|
HTTPServer(HTTPServerConfig config)
Prepare a server on localhost on the given port - use run() to start it.
|
HTTPServer(HTTPServerConfig config,
boolean runInternally)
Prepare a server on localhost on the given port - use run() to start it.
|
HTTPServer(HTTPServerConfig config,
boolean runInternally,
Set<String> allowedIps)
Prepare a server on localhost on the given port - use run() to start it.
|
HTTPServer(HTTPServerConfig config,
boolean runInternally,
String host,
Set<String> allowedIps)
Prepare a server on the given host and port - use run() to start it.
|
Modifier and Type | Method and Description |
---|---|
protected static void |
checkForNonRootUser() |
protected org.languagetool.server.ErrorRequestLimiter |
getErrorRequestLimiterOrNull(HTTPServerConfig config) |
protected ThreadPoolExecutor |
getExecutorService(HTTPServerConfig config) |
protected String |
getProtocol() |
protected org.languagetool.server.RequestLimiter |
getRequestLimiterOrNull(HTTPServerConfig config) |
boolean |
isRunning() |
static void |
main(String[] args) |
protected static void |
printCommonConfigFileOptions() |
protected static void |
printCommonOptions() |
void |
run()
Start the server.
|
void |
stop()
Stop the server.
|
protected static boolean |
usageRequested(String[] args) |
protected int port
protected String host
protected com.sun.net.httpserver.HttpServer server
protected org.languagetool.server.LanguageToolHttpHandler httpHandler
public HTTPServer()
public HTTPServer(HTTPServerConfig config)
PortBindingException
- if we cannot bind to the given port, e.g. because something else is running therepublic HTTPServer(HTTPServerConfig config, boolean runInternally)
runInternally
- if true, then the server was started from the GUI.PortBindingException
- if we cannot bind to the given port, e.g. because something else is running therepublic HTTPServer(HTTPServerConfig config, boolean runInternally, Set<String> allowedIps)
runInternally
- if true, then the server was started from the GUI.allowedIps
- the IP addresses from which connections are allowed or null
to allow any hostPortBindingException
- if we cannot bind to the given port, e.g. because something else is running therepublic HTTPServer(HTTPServerConfig config, boolean runInternally, String host, Set<String> allowedIps)
runInternally
- if true, then the server was started from the GUI.host
- the host to bind to, e.g. "localhost"
or null
to bind to any hostallowedIps
- the IP addresses from which connections are allowed or null
to allow any hostPortBindingException
- if we cannot bind to the given port, e.g. because something else is running therepublic void stop()
public static void main(String[] args)
protected String getProtocol()
public void run()
public boolean isRunning()
@Nullable protected org.languagetool.server.RequestLimiter getRequestLimiterOrNull(HTTPServerConfig config)
@Nullable protected org.languagetool.server.ErrorRequestLimiter getErrorRequestLimiterOrNull(HTTPServerConfig config)
protected static boolean usageRequested(String[] args)
protected static void printCommonConfigFileOptions()
protected static void printCommonOptions()
protected static void checkForNonRootUser()
protected ThreadPoolExecutor getExecutorService(HTTPServerConfig config)