Mercurial Hosting > luan
comparison src/goodjava/webserver/Connection.java @ 1736:a02a75e3daa8
webserver error handling
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 16 Oct 2022 11:44:23 -0600 |
parents | fa066aaa068c |
children | 9713f7fd50b3 |
comparison
equal
deleted
inserted
replaced
1735:4b56eff90040 | 1736:a02a75e3daa8 |
---|---|
24 this.server = server; | 24 this.server = server; |
25 this.socket = socket; | 25 this.socket = socket; |
26 } | 26 } |
27 | 27 |
28 private void handle() { | 28 private void handle() { |
29 String rawHead = ""; | |
29 try { | 30 try { |
30 Request request = new Request(); | 31 Request request = new Request(); |
31 Response response; | 32 Response response; |
32 String contentType = null; | 33 String contentType = null; |
33 try { | 34 try { |
59 System.arraycopy(a,0,a2,0,size); | 60 System.arraycopy(a,0,a2,0,size); |
60 a = a2; | 61 a = a2; |
61 left = a.length - size; | 62 left = a.length - size; |
62 } | 63 } |
63 } | 64 } |
64 String rawHead = new String(a,0,endOfHeader); | 65 rawHead = new String(a,0,endOfHeader); |
65 //System.out.println(rawHead); | 66 //System.out.println(rawHead); |
66 request.rawHead = rawHead; | 67 request.rawHead = rawHead; |
67 RequestParser parser = new RequestParser(request); | 68 RequestParser parser = new RequestParser(request); |
68 parser.parseHead(); | 69 parser.parseHead(); |
69 | 70 |
122 out.write(header); | 123 out.write(header); |
123 IoUtils.copyAll(response.body.content,out); | 124 IoUtils.copyAll(response.body.content,out); |
124 out.close(); | 125 out.close(); |
125 socket.close(); | 126 socket.close(); |
126 } catch(IOException e) { | 127 } catch(IOException e) { |
127 logger.info("",e); | 128 logger.info(rawHead.trim()+"\n",e); |
129 } catch(RuntimeException e) { | |
130 logger.error(rawHead.trim()+"\n",e); | |
131 throw e; | |
128 } | 132 } |
129 } | 133 } |
130 | 134 |
131 } | 135 } |