-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorker.java
More file actions
executable file
·58 lines (46 loc) · 1.37 KB
/
Worker.java
File metadata and controls
executable file
·58 lines (46 loc) · 1.37 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import java.io.IOException;
import java.net.Socket;
import conf.HttpdConf;
import conf.MimeTypes;
public class Worker implements Runnable {
private Socket client;
private MimeTypes mimeTypes;
private HttpdConf httpdConf;
public Worker(Socket client, MimeTypes mimeTypes, HttpdConf httpdConf) {
this.client = client;
this.mimeTypes = mimeTypes;
this.httpdConf = httpdConf;
}
public Socket getClient() {
return client;
}
public void setClient(Socket client) {
this.client = client;
}
public MimeTypes getMimeTypes() {
return mimeTypes;
}
public void setMimeTypes(MimeTypes mimeTypes) {
this.mimeTypes = mimeTypes;
}
public HttpdConf getHttpdConf() {
return httpdConf;
}
public void setHttpdConf(HttpdConf httpdConf) {
this.httpdConf = httpdConf;
}
@Override
public void run() {
try {
Request request = new Request(client);
Resource resource = new Resource(request.getUri(), httpdConf);
Response response = ResponseFactory.getResponse(request, resource);
String responsePhrase = response.getReasonPhrase();
client.close();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}