01: package vicazh.hyperpool.stream.net.http.html;
02:
03: import java.net.*;
04: import vicazh.hyperpool.Start;
05: import vicazh.hyperpool.stream.net.http.*;
06: import vicazh.hyperpool.stream.net.http.Session;
07:
08: class TaskConnection extends Connection implements Runnable {
09: TaskConnection(Service service) {
10: super (service);
11: }
12:
13: protected Session getSession() {
14: return new TaskSession(this );
15: }
16:
17: String address;
18:
19: int level;
20:
21: public void run() {
22: try {
23: URL url = new URL(address);
24: ((ClientStream) getClient().outputstream).head("GET", url
25: .getFile() == "" ? address + "/" : address,
26: "HTTP/1.1");
27: ((ClientStream) getClient().outputstream).field("Host", url
28: .getAuthority());
29: ((ClientStream) getClient().outputstream).field(
30: "User-Agent", Start.NAME + "/" + Start.VERSION);
31: ((ClientStream) getClient().outputstream).header();
32: getClient().flush();
33: } catch (Exception e) {
34: try {
35: getClient().close();
36: } catch (Exception ex) {
37: }
38: }
39: }
40:
41: public void remove(Session session) {
42: super .remove(session);
43: try {
44: if (getClient().outputstream != null
45: && !((TaskStream) session.getServer()).c)
46: ((Task) element).action(this );
47: } catch (Exception e) {
48: }
49: }
50: }
|