equal
deleted
inserted
replaced
102 he.close(); |
102 he.close(); |
103 } |
103 } |
104 }); |
104 }); |
105 |
105 |
106 server.setHttpsConfigurator(new Configurator(SSLContext.getDefault())); |
106 server.setHttpsConfigurator(new Configurator(SSLContext.getDefault())); |
107 server.bind(new InetSocketAddress(0), 0); |
107 InetSocketAddress addr = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); |
|
108 server.bind(addr, 0); |
108 return server; |
109 return server; |
109 } |
110 } |
110 |
111 |
111 public static void main(String[] args) |
112 public static void main(String[] args) |
112 throws IOException, |
113 throws IOException, |
240 accept = new Thread(this::accept); |
241 accept = new Thread(this::accept); |
241 accept.setDaemon(true); |
242 accept.setDaemon(true); |
242 } |
243 } |
243 |
244 |
244 void start() throws IOException { |
245 void start() throws IOException { |
245 ss.bind(new InetSocketAddress(0)); |
246 ss.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0)); |
246 accept.start(); |
247 accept.start(); |
247 } |
248 } |
248 |
249 |
249 // Pipe the input stream to the output stream. |
250 // Pipe the input stream to the output stream. |
250 private synchronized Thread pipe(InputStream is, OutputStream os, |
251 private synchronized Thread pipe(InputStream is, OutputStream os, |
274 } |
275 } |
275 }; |
276 }; |
276 } |
277 } |
277 |
278 |
278 public InetSocketAddress getAddress() { |
279 public InetSocketAddress getAddress() { |
279 return new InetSocketAddress( |
280 return new InetSocketAddress(InetAddress.getLoopbackAddress(), |
280 "localhost", |
281 ss.getLocalPort()); |
281 ss.getLocalPort()); |
|
282 } |
282 } |
283 |
283 |
284 // This is a bit shaky. It doesn't handle continuation |
284 // This is a bit shaky. It doesn't handle continuation |
285 // lines, but our client shouldn't send any. |
285 // lines, but our client shouldn't send any. |
286 // Read a line from the input stream, swallowing the final |
286 // Read a line from the input stream, swallowing the final |