blob: 3d5c1b2aa1f9128ee461144d33d761af5c425293 (
plain) (
blame)
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
|
package org.eclipse.help.internal.server;
/*
* Licensed Materials - Property of IBM,
* WebSphere Studio Workbench
* (c) Copyright IBM Corp 2000
*/
import java.net.*;
import java.io.*;
import java.util.*;
import java.util.zip.*;
import org.eclipse.help.internal.util.Logger;
/**
* Thread server class to handle clients.
*/
class HelpHttpConnection extends Thread {
Socket client; // client socket
// Pass the socket as a argument to the constructor
HelpHttpConnection(Socket client) throws SocketException {
this.client = client;
// Set the thread priority down so that the ServerSocket
// will be responsive to new clients.
setPriority(NORM_PRIORITY - 1);
setName("Connection");
}
/**
* Handles a connection request.
* NOTE: move some of the constants to properties and do better
* handling of requests, including SECURITY issues (originating machine, etc.)
**/
public void handleRequest() {
try {
HelpHttpRequest request = new HelpHttpRequest(client.getInputStream());
HelpHttpResponse response =
new HelpHttpResponse(client.getOutputStream(), request);
request.processRequest(response);
client.close(); // close the client socket
} catch (IOException e) {
Logger.logDebugMessage(
"HelpHttpConnection",
"connection failed: " + e.getMessage());
}
}
/**
* Handles a connection request.
**/
public void run() {
handleRequest();
}
}
|