192 fac = SSLServerSocketFactory.getDefault(); |
192 fac = SSLServerSocketFactory.getDefault(); |
193 } |
193 } |
194 SSLServerSocket se = (SSLServerSocket) fac.createServerSocket(port); |
194 SSLServerSocket se = (SSLServerSocket) fac.createServerSocket(port); |
195 SSLParameters sslp = se.getSSLParameters(); |
195 SSLParameters sslp = se.getSSLParameters(); |
196 sslp.setApplicationProtocols(new String[]{"h2"}); |
196 sslp.setApplicationProtocols(new String[]{"h2"}); |
|
197 sslp.setEndpointIdentificationAlgorithm("HTTPS"); |
197 se.setSSLParameters(sslp); |
198 se.setSSLParameters(sslp); |
198 se.setEnabledCipherSuites(se.getSupportedCipherSuites()); |
199 se.setEnabledCipherSuites(se.getSupportedCipherSuites()); |
199 se.setEnabledProtocols(se.getSupportedProtocols()); |
200 se.setEnabledProtocols(se.getSupportedProtocols()); |
200 // other initialisation here |
201 // other initialisation here |
201 return se; |
202 return se; |
220 public void start() { |
221 public void start() { |
221 exec.submit(() -> { |
222 exec.submit(() -> { |
222 try { |
223 try { |
223 while (!stopping) { |
224 while (!stopping) { |
224 Socket socket = server.accept(); |
225 Socket socket = server.accept(); |
225 InetSocketAddress addr = (InetSocketAddress) socket.getRemoteSocketAddress(); |
226 Http2TestServerConnection c = null; |
226 Http2TestServerConnection c = |
227 InetSocketAddress addr = null; |
227 new Http2TestServerConnection(this, socket, exchangeSupplier); |
|
228 putConnection(addr, c); |
|
229 try { |
228 try { |
|
229 addr = (InetSocketAddress) socket.getRemoteSocketAddress(); |
|
230 c = new Http2TestServerConnection(this, socket, exchangeSupplier); |
|
231 putConnection(addr, c); |
230 c.run(); |
232 c.run(); |
231 } catch (Throwable e) { |
233 } catch (Throwable e) { |
232 // we should not reach here, but if we do |
234 // we should not reach here, but if we do |
233 // the connection might not have been closed |
235 // the connection might not have been closed |
234 // and if so then the client might wait |
236 // and if so then the client might wait |
235 // forever. |
237 // forever. |
236 removeConnection(addr, c); |
238 if (c != null) { |
237 c.close(ErrorFrame.PROTOCOL_ERROR); |
239 removeConnection(addr, c); |
|
240 c.close(ErrorFrame.PROTOCOL_ERROR); |
|
241 } |
238 System.err.println("TestServer: start exception: " + e); |
242 System.err.println("TestServer: start exception: " + e); |
239 //throw e; |
243 //throw e; |
240 } |
244 } |
241 } |
245 } |
242 } catch (Throwable e) { |
246 } catch (Throwable e) { |