commit | author | age
|
0c8d27
|
1 |
/* |
U |
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package de.uhilger.avdirektor.handler; |
|
7 |
|
|
8 |
import com.sun.net.httpserver.HttpExchange; |
|
9 |
import com.sun.net.httpserver.HttpHandler; |
|
10 |
import java.io.IOException; |
|
11 |
import java.io.OutputStream; |
|
12 |
import java.util.logging.Level; |
|
13 |
import java.util.logging.Logger; |
|
14 |
|
|
15 |
/** |
|
16 |
* |
|
17 |
* @author ulrich |
|
18 |
*/ |
|
19 |
public class PingHandler implements HttpHandler { |
|
20 |
|
|
21 |
private static final Logger logger = Logger.getLogger(PingHandler.class.getName()); |
|
22 |
|
|
23 |
@Override |
|
24 |
public void handle(HttpExchange t) throws IOException { |
|
25 |
logger.log(Level.FINE, "RequestURI: {0}", t.getRequestURI().toString()); |
|
26 |
|
cc2a32
|
27 |
String response = "ping"; |
0c8d27
|
28 |
t.sendResponseHeaders(200, response.length()); |
U |
29 |
OutputStream os = t.getResponseBody(); |
|
30 |
os.write(response.getBytes()); |
|
31 |
os.close(); |
|
32 |
} |
|
33 |
|
|
34 |
} |