Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void run() {
- try {
- System.out.println("Connection from "+socket.getRemoteSocketAddress());
- BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
- PrintStream out = new PrintStream(socket.getOutputStream());
- while((line = input.readLine()) != null){
- System.out.println("SERVER: "+line);
- if(!parser.execute(line, request)){
- System.out.println("here");
- response = handler.handle(request);
- String ret = response.toString();
- out.println(ret);
- String connection = request.getConnection();
- if(connection.equals("close")){
- System.out.println("Connection terminated by client");
- break;
- }
- if(response.getClass()==Response404.class){
- System.out.println("Bad Request to: " + request.getRequestURI());
- break;
- }
- }
- System.out.println("END WHILE");
- }
- // TODO: Send Connection Close message
- socket.close();
- }catch (SocketException e){
- System.out.println("Socket closed by Client");
- }catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- // TODO Auto-generated method stub
- }
Add Comment
Please, Sign In to add comment