/*
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.apache.coyote.http2;

import javax.servlet.http.WebConnection;

import org.apache.coyote.http11.upgrade.InternalHttpUpgradeHandler;
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
import org.apache.tomcat.util.net.SocketStatus;
import org.apache.tomcat.util.net.SocketWrapperBase;

public class Http2UpgradeHandler implements InternalHttpUpgradeHandler {

    @Override
    public void init(WebConnection connection) {
        // TODO Auto-generated method stub
    }

    @Override
    public void setSocketWrapper(SocketWrapperBase<?> wrapper) {
        // TODO Auto-generated method stub
    }

    @Override
    public SocketState upgradeDispatch(SocketStatus status) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public void destroy() {
        // TODO Auto-generated method stub
    }
}

@@ -841,16 +841,45 @@
 http2;%0A%0A
+import java.io.IOException;%0A%0A
 import j
@@ -980,16 +980,95 @@
 andler;%0A
+import org.apache.juli.logging.Log;%0Aimport org.apache.juli.logging.LogFactory;%0A
 import o
@@ -1237,80 +1237,441 @@
 e;%0A%0A
-public class Http2UpgradeHandler implements InternalHttpUpgradeHandler %7B
+/**%0A * This represents an HTTP/2 connection from a client to Tomcat. It is designed%0A * on the basis that there will never be more than one thread performing I/O at%0A * a time.%0A */%0Apublic class Http2UpgradeHandler implements InternalHttpUpgradeHandler %7B%0A%0A    private static final Log log = LogFactory.getLog(Http2UpgradeHandler.class);%0A%0A    private SocketWrapperBase%3C?%3E socketWrapper;%0A    private volatile boolean initialized = false;%0A
 %0A%0A  
@@ -1717,26 +1717,22 @@
 nection 
-connection
+unused
 ) %7B%0A    
@@ -1739,50 +1739,35 @@
     
-// TODO Auto-generated method stub
+initialized = true;
 %0A    %7D%0A%0A
     
@@ -1754,32 +1754,33 @@
  = true;%0A    %7D%0A%0A
+%0A
     @Override%0A  
@@ -1854,50 +1854,45 @@
     
-// TODO Auto-generated method stub
+this.socketWrapper = wrapper;
 %0A    %7D%0A%0A
     
@@ -1879,32 +1879,33 @@
 wrapper;%0A    %7D%0A%0A
+%0A
     @Override%0A  
@@ -1976,62 +1976,473 @@
     
-// TODO Auto-generated method stub%0A        return null
+if (!initialized) %7B%0A            // WebConnection is not used so passing null here is fine%0A            init(null);%0A        %7D%0A%0A        // TODO This is for debug purposes to make sure ALPN is working.%0A        log.fatal(%22TODO: Handle SocketStatus: %22 + status);%0A%0A        try %7B%0A            socketWrapper.close();%0A        %7D catch (IOException e) %7B%0A            // TODO Auto-generated catch block%0A            e.printStackTrace();%0A        %7D%0A%0A        return SocketState.CLOSED
 ;%0A  
@@ -2442,24 +2442,25 @@
 SED;%0A    %7D%0A%0A
+%0A
     @Overrid
@@ -2504,39 +2504,13 @@
  // 
-TODO Auto-generated method stub
+NO-OP
 %0A   

Handle init for HTTP upgrade vs ALPN. Add some debug code to confirm ALPN is working.