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 |
|
|
24 |
@Override |
|
25 |
public void handle(HttpExchange t) throws IOException { |
|
26 |
logger.log(Level.FINE, "RequestURI: {0}", t.getRequestURI().toString()); |
|
27 |
|
|
28 |
String antwort = "ping Antwort"; |
|
29 |
|
|
30 |
String response = antwort; |
|
31 |
t.sendResponseHeaders(200, response.length()); |
|
32 |
OutputStream os = t.getResponseBody(); |
|
33 |
os.write(response.getBytes()); |
|
34 |
os.close(); |
|
35 |
|
|
36 |
|
|
37 |
} |
|
38 |
|
|
39 |
} |