// Path: src/org/httpkit/ProtocolException.java
// public class ProtocolException extends HTTPException {
// 
//     private static final long serialVersionUID = 1L;
// 
//     public ProtocolException(String msg) {
//         super(msg);
//     }
// }
// 
// Path: src/org/httpkit/HttpUtils.java
// public static final byte SP = 32;
// 
// Path: src/org/httpkit/HttpUtils.java
// public static InetSocketAddress getServerAddr(URI uri) throws UnknownHostException {
//     InetAddress host = getByName(uri.getHost());
//     return new InetSocketAddress(host, getPort(uri));
// }


import org.httpkit.*;
import org.httpkit.ProtocolException;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLException;
import java.io.IOException;
import java.net.*;
import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
import java.security.NoSuchAlgorithmException;
import java.util.Iterator;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicInteger;
import static java.lang.System.currentTimeMillis;
import static java.nio.channels.SelectionKey.*;
import static org.httpkit.HttpUtils.SP;
import static org.httpkit.HttpUtils.getServerAddr;
import static org.httpkit.client.State.ALL_READ;
import static org.httpkit.client.State.READ_INITIAL;
                req.finish(e);
            }
        } catch (Exception e) { // rarely happen
            req.finish(e);
        }
    }

    public void exec(String url, RequestConfig cfg, SSLEngine engine, IRespListener cb) {
        URI uri;
        try {
            uri = new URI(url);
        } catch (URISyntaxException e) {
            cb.onThrowable(e);
            return;
        }

        if (uri.getHost() == null) {
            cb.onThrowable(new IllegalArgumentException("host is null: " + url));
            return;
        }

        String scheme = uri.getScheme();
        if (!"http".equals(scheme) && !"https".equals(scheme)) {
            String message = (scheme == null) ? "No protocol specified" : scheme + " is not supported";
            cb.onThrowable(new ProtocolException(message));
            return;
        }

        InetSocketAddress addr;
        try {
// Path: src/org/httpkit/ProtocolException.java
// public class ProtocolException extends HTTPException {
// 
//     private static final long serialVersionUID = 1L;
// 
//     public ProtocolException(String msg) {
//         super(msg);
//     }
// }
// 
// Path: src/org/httpkit/HttpUtils.java
// public static final byte SP = 32;
// 
// Path: src/org/httpkit/HttpUtils.java
// public static InetSocketAddress getServerAddr(URI uri) throws UnknownHostException {
//     InetAddress host = getByName(uri.getHost());
//     return new InetSocketAddress(host, getPort(uri));
// }


// Path: src/org/httpkit/client/HttpClient.java
import org.httpkit.*;
import org.httpkit.ProtocolException;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLException;
import java.io.IOException;
import java.net.*;
import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
import java.security.NoSuchAlgorithmException;
import java.util.Iterator;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicInteger;
import static java.lang.System.currentTimeMillis;
import static java.nio.channels.SelectionKey.*;
import static org.httpkit.HttpUtils.SP;
import static org.httpkit.HttpUtils.getServerAddr;
import static org.httpkit.client.State.ALL_READ;
import static org.httpkit.client.State.READ_INITIAL;

                req.finish(e);
            }
        } catch (Exception e) { // rarely happen
            req.finish(e);
        }
    }

    public void exec(String url, RequestConfig cfg, SSLEngine engine, IRespListener cb) {
        URI uri;
        try {
            uri = new URI(url);
        } catch (URISyntaxException e) {
            cb.onThrowable(e);
            return;
        }

        if (uri.getHost() == null) {
            cb.onThrowable(new IllegalArgumentException("host is null: " + url));
            return;
        }

        String scheme = uri.getScheme();
        if (!"http".equals(scheme) && !"https".equals(scheme)) {
            String message = (scheme == null) ? "No protocol specified" : scheme + " is not supported";
            cb.onThrowable(new ProtocolException(message));
            return;
        }

        InetSocketAddress addr;
        try {
            addr = getServerAddr(uri);