-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInstance.java
30 lines (25 loc) · 878 Bytes
/
Instance.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package WebServer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.Socket;
public class Instance extends Thread {
public Socket handler;
public RequestHeader headers;
public Route route;
public Instance(Socket client) throws Exception {
this.handler = client;
}
public void run() {
try {
BufferedReader requestPacket = new BufferedReader(new InputStreamReader(handler.getInputStream()));
this.route = new Route(requestPacket.readLine());
this.headers = new RequestHeader(requestPacket);
} catch (Exception e) {
System.out.println("Exception occured");
}
}
public void send(String result) throws Exception {
this.handler.getOutputStream().write(result.getBytes());
this.handler.getOutputStream().flush();
}
}